Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r.string error "cannot be resolved or is not a field"

Tags:

android

I just opened an older android app project and all of a sudden numerous R.string._var_Name errors were found. If I add "import android.R" then the _var_name becomes an issue saying "cannot be resolved or is not a field". The translation is in /res/values/strings.xml . Any ideas why the error exists?

like image 547
Jim Avatar asked Oct 28 '11 18:10

Jim


2 Answers

If your class files are not in your root package, you'll need to import them at the top of your file like this:

your.package.name.R
like image 97
Kurtis Nusbaum Avatar answered Oct 18 '22 12:10

Kurtis Nusbaum


In my case import android.R was usually the problem. I then removed it and build again (eclipse) and than it worked. Cleaning the project often helps too.

like image 26
drakon Avatar answered Oct 18 '22 11:10

drakon