Android Eclipse - moving project caused all R refe

2019-03-01 03:28发布

问题:

I moved my project on Eclipse by Right Click project > Refactor > Move. This caused (at first) an exclamation mark to show next to project name. So I restarted Eclipse. This removed the exclmation mark, but now my entire Activity file's R. references have errors. I tried:

  1. Deleting R.java file and it regenerated automatically.

  2. Cleaned the project few times.

  3. Changed target build set back and forth. Still no luck.

There are no errors anywhere else. Just my MainActivity file inside src\com.* folder.

回答1:

Check if you are importing android.R instead of your generated R class.

From Using Eclipse:

Note: Eclipse sometimes likes to add an import android.R statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these erroneous import statements and delete them.

In the other hand, check if you have any errors in a xml file (but it shouldn´t allow you to generate the R.java file)



回答2:

Are you creating Project name folder to another workspace on move??