简体   繁体   中英

Cleaning Project not fixing R.java errors (Android)

My Android project just started saying all my R.blah.blah references are errors. Cleaning/re-generating the R.java file has not fixed it. Nor has closing/reopening the project/eclipse. I undid any changes to xml files that could have caused it. This is only occurring in ONE of my activities, all other activities do not have any errors related to R.blah.

Note: R.java does have all the correct references in the file.

check if

import android.R;

is in your classes and remove it then try

If you copy code from other project you get some,lines like

import android.R.com.example.view.Widget
import android.R.com.hardware.Camera 

Remove those lines and run it.

To avoid the hussle ,another simple solution is to restart eclipse. This time change the directory of your workspace. And import your project from the previous workspace into the new one . Viola.it works. So far as you have not violated naming conventions in your xml files (Remember all ids in xml must be small letters) . This should work.

这可能是您的xml数据错误。请检查您的xml文件, 请参阅此处 ,然后清理您的项目并构建它。检查R.java文件是否自动生成。

只是在发生错误的特定活动中尝试一下

    import your_package_name.R;

The line android:text="@string/Get Location" causes as error in R.java because string Get Location have a gap in it.

To correct it use an underscore between two names: Get_Location

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM