gen already exists but is not a source folder

2019-01-30 02:57发布

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 folder. Convert to a source folder or rename it

In my Activity code, all resources from R.java can not be resolved.

I tried, right click on my project => Java Build Path => under "Source" tab, I added gen/ as source. But it does not help with the problem...

Why, how to get rid of this problem?

----UPDATE----

I found that, the eclipse also complain that "Project has no project.properties file! Edit the project properties to set one." , but I do have project.properties file under my project. Why it complains? I have cleaned the project and "fix project properties" but it does not help.

15条回答
Root(大扎)
2楼-- · 2019-01-30 03:07

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 :)

查看更多
姐就是有狂的资本
3楼-- · 2019-01-30 03:08

I get the same problem.

Two actions, first:

    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"

second: (because the previous action asked me to remove something... I do not remember what it was...)

    1. Right click on the project and go to "Properties"
    2. Select "Java Build Path" on the left
    3. Open Libraries "tab"
    4. Add an external JAR. Add the Google API that is in your android directory (android-sdk\platforms\android-yourversion

And now it works for me!

查看更多
地球回转人心会变
4楼-- · 2019-01-30 03:08

I had SVN configured for a project with the same problem, deleted all folders and files, retrieved it again from SVN and still no luck. The only thing that helped was reverting the changes, and deleting/re-importing projects to the workspace. Hope this helps

查看更多
甜甜的少女心
5楼-- · 2019-01-30 03:11

Go to the project properties then Go to Java Build Path then Remove already exist folder then Click Add Folder then Add the Source and gen folder. then Press ok............It will work.......

查看更多
地球回转人心会变
6楼-- · 2019-01-30 03:11

I tried the suggestions given here and still had the problem. Finally, it turned out that Eclipse got its imports wrong. For some reason it added the words "gen" and "src" to the beginning of the import line. I had to change all the import lines from

import gen.org.qtproject.qt5.android.bindings.QtApplication;

to

import org.qtproject.qt5.android.bindings.QtApplication;

Once I did that, everything came back to normal.

查看更多
太酷不给撩
7楼-- · 2019-01-30 03:12

The last time I had this issue, it was because I switched the source to another branch behind the scenes. Once I closed Eclipse and relaunched, the issue went away.

查看更多
登录 后发表回答