Reputation: 1026
Editing the xml
files didn't help, cleaning the project didn't help and, of course, trying to run the project didn't help because the project contains errors (because it cannot see R
class). This project cannot contain errors in resources
because it is a project from other people, and it works on their computers. Also, when I create new android project, it cannot run becauseof the same - no R class.
On OS Windows it sometimes works (after some changes in project files, or re-opening eclipse), but now it is Ubuntu and android sdk for linux.
How to solve this problem?
Upvotes: 0
Views: 2810
Reputation: 36
R is usually automatically generated, but here are some exceptions:
1.) There is an error in the res folder. Resolve by fixing the rogue file.
2.) The project was only partially cleaned. When selecting Project > Clean , select "Clean all projects".
Upvotes: 0
Reputation: 19385
May be your installation lacks some of libraries ,,,, run the below code in terminal ...
sudo apt-get install lib32ncurses5 lib32stdc++6 zlib1g:i386 libc6-i386
Upvotes: 0
Reputation: 1
If you have tried all of the above and it doesn't look like you have any errors; check your errors counsel. In my case, in the res directory eclipse automatically generated a menu folder with a main.xml. Because I didn't incorporate a menu; res/menu/main.xml created conflicts. I deleted this and it worked.
res/menu/main.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/action_settings').
Upvotes: 0
Reputation: 1026
SOLUTION:
WOW! This problem has a really EPIC solution! So, what to do? When you install android-sdk for linux, you are unpacking .tgz file which contains different tools. BUT! The tools are executable files, but they haven't executable flag! So, You should do it manually! In the folders tools/ and platform-tools/ it is necessary to do it. In this concrete case: the tool "aapt" generates the R class, so I did:
chmod +x platform-tools/aapt After that, eclipse COULD generate the R-class.
I hope this message helps someone in the future.
Upvotes: 0
Reputation: 26
Use Build Project option followed by the cleaning of project.
Or your project java classes might have imported android.R instead of project specific R file.
For this issue you can go with the following step by step method.
1) Remove import android.R;
2) Save the particular java class.
3) Clean the project.
4) Build it again.
Your project will work fine. Just check it out.
Upvotes: 0
Reputation: 177
I had the exact same issue (the R class was missing)
Running Ubuntu 12.04 64-bit and ADT Build: v21.1.0.
Checked Window>Show View>Problems and saw this:
Hint: On 64-bit systems, make sure the 32-bit libraries are installed: sudo apt-get install ia32-libs
Exited Eclipse/ADT, then installed libraries using terminal:
sudo apt-get install ia32-libs
When Eclipse/ADT re-started, the R class file was generated automatically.
Upvotes: 0
Reputation: 80340
R
is generated. You can delete the whole gen
directory and it will get generated again - this is what you should do in your case.
Also you should not ship R
to other people (or accept it from other people). This also means not putting it into version control.
Btw, are you getting code from 3rd party in binary form and it includes R
? This would not work - compiled libraries on Android can not contain resource files. At least not before SDK r14. http://developer.android.com/guide/developing/projects/index.html#LibraryProjects
Update
R
file will not be generated if there are errors in res
directory. Delete the gen
directory, then right click on the project -> android -> fix android settings.
Upvotes: 2
Reputation: 1822
Please try to check files under /res/ folder, file name should be lowercase, chars in files. It was caused by these resource files.
Upvotes: 0