Reputation: 1200
I am building an application and I added a new activity to generate a view. I compiled it. My application can not find anything that is on the format R.id.xxx
or R.layout.xxx
, I've tried also cleaning my project, closing Eclipse and opening Eclipse again, but nothing. The most strange thing is that before everything was working well. But now it can not recognize even the R.layout.main
that is default of my principal activity. Anyone have an idea?
Also I have tried almost everything here: R cannot be resolved - Android error but no result!
Solved
Thanks to woopsy, also I found the reference to this kind of problem
http://source.android.com/source/using-eclipse.html
it happens because Eclipse sometimes imports R when you press the combination ctrl+shift+O
Upvotes: 1
Views: 2793
Reputation: 77
This problem can fix with this process: - File---->Invalidate cache/restart.
it will restart your android studio and fix that problem
Upvotes: 0
Reputation: 1
I found the solution...For me works it
Poject->Properties->Android->Project Build Target (here choose android4.4 or 5.1.1 Android Open Source Project)->Ok Project->Build All
This function ...
Upvotes: 0
Reputation: 1
friends take care that u haven't imported R class, if you have delete "import android.R". The reason is there are two R things one R.java and R.class and we need the java, where we dont need to import rather than referring it. It worked for me and may be to you too.
Upvotes: 0
Reputation: 51
this is a common error. You need to just search your R.java file in generated section of your project directory in Eclipse. Need to import if the R.java file into the package then import . R; I hope it will work for you. It was absolutely worked for me...enjoy programming
Upvotes: 0
Reputation: 3377
Remove all your imports for the Activity and then have eclipse fix imports. I have had problems where eclipse wants to import a different R than the one I need.
Upvotes: 4
Reputation: 40416
First of All Check You have R.java File then check
import android.R;
Enter Yourpackages like import com.mypackages.prj;
Upvotes: 2
Reputation: 68177
check your xml files. there might be something wrong in it which is causing R not to build up automatically. To observe such errors, switch your view to Console
tab
Upvotes: 0
Reputation: 7631
If you are using eclipse, take a backup of your layout main.xml file and then from the eclipse new file interface create a new "Android XML File" and call it main.xml. copy back from the backup the contents into this new file.
try this.
Upvotes: 0