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条回答
看我几分像从前
2楼-- · 2019-01-30 03:26

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.

查看更多
The star\"
3楼-- · 2019-01-30 03:30

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>
查看更多
一夜七次
4楼-- · 2019-01-30 03:32

This is caused by using the wrong importer in Eclipse. If you have Android projects, you need to import them into your workspace with Android->Existing Android Code, not General->Existing Projects.

enter image description here

查看更多
登录 后发表回答