问题
R.java file is not getting generated for new Android projects in eclipse and Android studio. This happened after i updated
Android SDK Tools -> 24.4.1 (latest version)
Android SDK Platform-tools -> 23.1 (latest version)
Android SDK Build-tools -> 23.0.2 (latest version)
Before that i don't remember what versions i used, but eclipse and android studio used to work fine.
Searched for R.java not generated over stackoverflow and some other googled websites but my problem is not resolved.
Tried Project -> Clean and Build not worked and also deleted gen/ folder and build but still R.java not generated.
Tried checking the mistakes in xml naming and data for mistakes but found none.
Also tried right click on MyProject -> properties -> Java Build Path all libraries ticked.
Tried using android-studio and created new project, it also shows error at R in MainActivity class.
Also tried updating packages to latest versions(already latest versions) and installed all Build-tools.
I use Ubuntu 14.04 LTS version. For this question Developing for Android in Eclipse: R.java not regenerating Nevin Chen suggested to install ia32-libs library for ubuntu. But that library is removed after Ubuntu 13 version. Unable to install that library.
Tried importing existing android project into eclipse, tried to run the project but it shows a dialog saying project has errors (at this point i still have R.java file from my imported project not deleted while importing). But after i try to clean and build the project, R.java file from my imported project is deleted and MainActivity class is showing errors at R.
Finally i deleted android-sdk-linux, eclipse and all related configuration files . Downloaded the latest android-sdk-linux from developer.android.com and reinstalled both android-sdk-linux, eclipse with adt plugin. Well nothing changed, when i created a new project with new workspace its still not generating R.java file.
None of the solutions of questions found for R.java file not generating over statckoverflow are not working solutions to my problem. I still can't fix the issue of not generating the R.java file in my projects. So don't mark it as duplicate.
回答1:
Many times it happens when you do not rename resources properly as per conventions. For Example if you insert a number in resource file name, or put a space between file name or string/color/dimens/style name etc.
Please check naming once.
回答2:
Found a solution to my problem. Its the problem with the system 64bit architecture but not with eclipse or android studio. Android SDK is designed for 32bit architecture so i needed to install 32 bit libraries in my 64 bit Ubuntu. Here are the missing libraries
sudo apt-get install lib32z1
sudo apt-get install lib32stdcc++6
installing these libraries solved my issue. Found solution, @Denis Uyeda answer in R.java file not getting generated.
来源:https://stackoverflow.com/questions/34428240/r-java-file-not-generated-when-creating-new-android-project-in-eclipse-and-andro