gen already exists but is not a source folder

前端 未结 15 1049
深忆病人
深忆病人 2020-12-22 23:37

I am developing my Android project, After I removed a unused library, I got the error:

myproject/gen already exists but is not a source fold         


        
相关标签:
15条回答
  • 2020-12-22 23:48

    My solution was to paste the following into the .classpath file:

    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="output" path="bin/classes"/>
    </classpath>
    
    0 讨论(0)
  • 2020-12-22 23:50

    I had some of the same symptoms, but solved it differently:

    I found out that I had two files in the drawable dir that were conflicting: icon.png and icon.xcf. This made R fail generation. I moved the icon.xcf out of the way and R generated and the project compiled.

    0 讨论(0)
  • 2020-12-22 23:53
    1. Right click on the project and go to Properties
    2. Select Java Build Path on the left
    3. Open Source tab
    4. Click Add Folder... and check gen and src
    0 讨论(0)
  • 2020-12-22 23:53

    I met the same problem, solved it as following:

    In Package Explorer, right-click the gen folder, find "Build Path - Use as Source Folder" and click it.

    That is it. I hope it will help.

    0 讨论(0)
  • 2020-12-22 23:54

    Solution :

    Step 1 :

    • Right click on the project and go to "Properties"
    • Select "Java Build Path"
    • Switch to "Source" tab Remove all sources from source folder on Build Path
    • Restart Eclipse

    Step 2 :

    • Right click on the project and go to "Properties"
    • Select "Java Build Path"
    • Switch to "Source" tab
    • Click "Add Folder..." and check "gen" and "src" source folder on Build Path
    • Restart Eclipse

    Final

    Build Project(s)

    Happy Coder :)

    0 讨论(0)
  • 2020-12-22 23:55

    The gen folder is where ADT creates the R.java file, which specifies your resource definitions. i.e. your resources (colours, dimensions, layouts, etc) are converted to code, and placed in R.java in the gen folder.

    So when you build the app you need to ensure the gen folder is treated as a source code folder by your IDE, as it contains the R class.

    In your IDE, you need to mark the gen folder as a source folder, so its content are built alongside your source.

    Your acceptance rate is very low. If you want people to help you, you need a high acceptance rate.

    0 讨论(0)
提交回复
热议问题