Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R cannot be resolved - Android, no import android.R; statement

Ok, I am working on a new app and everything worked fine as long as I used a Relative View. However, I want a tabbed layout so I switched what I had (not much so far since I just got it reading from a DB and settings working) over to a tabbed view. Since that time, any class that has any R. statement in it has an "R cannot be resolved" error. I am following the tutorial from the Android "Hello Views" tutorial so I am assuming that isn't the issue (but it could still be).

like image 880
smccloud Avatar asked Apr 25 '11 17:04

smccloud


2 Answers

I have a few suggestions:

  1. Make sure you don't have any other errors other than the R-related errors. Right-click your project folder in Eclipse, Android Tools -> Fix Project Properties.

  2. Check to make sure you have the correct R imported. Sometimes the default Android.R can be imported.

  3. Check for errors in your layout XML files.

like image 61
Haphazard Avatar answered Nov 02 '22 23:11

Haphazard


  1. You can try to "clean" your project.
  2. The default tech solution helps sometimes: restart Eclipse (seriously)
  3. If you have an error (something in your XML maybe, or something else), R cannot be compiled. If this is the case, try to find the first error noted. If you fix this, R will be compiled and found. If necesairy, use point 1. and 2. after fixing stuff.
  4. Remove all "import R" stuff in the import sections. You don't want that.
like image 28
Nanne Avatar answered Nov 02 '22 23:11

Nanne