问题
I have updated my SDK
and ADT
to the latest version, I have also update the Eclipse
to Kepler
the latest one after Juno
.
My ADT
version is 22.0
. After this update when I create a new project, I\'m getting error, stating R cannot be resolved to a variable
. I have imported import android.R;
, but it is showing as unused import stating Don\'t include android.R here; use a fully qualified name for each usage instead
.
Same thing is happening with Mac OS also with the latest update. I have tried renaming activity_main.xml
to other name, but still my R.java
is not generated.
Tried all the things which are possible. Cleaned the project, build the whole workspace. Nothing helping.
I think ADT
or Eclipse
compatibility is having problem after the update.
I have updated my whole SDK, here is the screenshot, but same problem is there.
回答1:
After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools.
After installing this, clean your projects and rebuild.
回答2:
Yesterday, I made an update with sdk manager, and I had the same problem as you. I fixed the issue: I have updated another time the android sdk (with the sdk manager tool), then I check update from eclipse for install the updated ADT plugin and I rebuid my project. "Android sdk Build-tools" from Android sdk manager is now rev 17 and now it is OK. I think the issue is from adt plugin from eclipse
回答3:
import android.R - remove this statement from all your classes and then do a clean your R file will be generated. if this did not work then check all your xml files for any errors and then do a clean. These 2 are the most common reasons for R file to go missing
回答4:
Changes in your Build target also can effect R.java in Eclipse so
Right Click Project >> Properties >> Android >> Select Latest(usually) Android API Platform >> Click OK
Hope this is helpful.
回答5:
Follow These steps...
- Right Click Your Project.
- Select Properties->Android Check Project Build Target and API Level.
- Again come back and open Android Sdk Manager Chekc the Tools and make sure you are installed Curresponding Android SDK Build Tools.
Eg : IF you selected api level 17 in properties you should install Android SDK Build Tools 17..
回答6:
Try this:
make a backup of your projects on desktop
close eclipse
delete your workspace
restart eclipse and import your projects again.
回答7:
I had same problem.. I solved by doing the following:
check all xml files and drawable files if there are any CAPITAL LETTERS in file name, if you have then change it to lower case, if you are using selector xml files then check the other files you are linking in those files..all should be lower case.
Go to java files which show error and remove IMPORT R.java file from imports list.
Go to Projects>>Clean.
This should fix the problem. This is how i fixed :)
回答8:
My issue was that I had android:orientation misspelled in my activity_main.xml file and I was getting this error. I fixed the spelling and problem went away! So make sure activity_main.xml doesn't have any errors in it.
回答9:
Sometimes when you extract your file it miss some part so better when its extracting make sure all file are extracting properly and then run eclipse after that run a simple file and install plugin of avd it helped in my case
回答10:
if the problem persists then try closing the other projects by
right click -> close Unrelated projects !
this worked in my case
回答11:
For eclipse users: Comment the lines including R.* Clean and build. R.java will be generated and then uncomment the R.* and rebuild.
回答12:
the best solution for r.java missing for linux... R.java is self generated in gen folder.. so better dont edit or create manually by urself ..
-open terminal(alt + ctrl + t) -change directory to skd->tools -then provide executive attribute to all executable file by(sudo chmod +x filename) -do the same for files in sdk->platform tools .. (ie sudo chmod +x filename) .. -----every executable file sud b provided with +x attribute...
回答13:
just delete gen folder all of your error will be cleared
回答14:
Proven successful method, check the file (AndroidManifest.xml) and delete all comments in it, and make sure there are no errors in this file, I tried and did work with me.
来源:https://stackoverflow.com/questions/16608524/eclipse-giving-error-missing-r-java-file-after-recent-update