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

前端 未结 10 1083
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 03:55

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

相关标签:
10条回答
  • 2020-12-11 04:46

    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.

    0 讨论(0)
  • 2020-12-11 04:46

    You should import your own projects R class rather than androids default R class ie.
    your.app.package.R

    This will make the values defined under the res folder in your class . After that refresh and then clean your project .

    0 讨论(0)
  • 2020-12-11 04:48

    If anything in your 'res' directory is named using illegal characters, this can happen.

    Note that android only allows lower case letters (no capitals!!!), numerals, and the underscore. THAT'S ALL!

    Almost every operating system allows other characters, so moving a file into your 'res' directory can easily create this problem.

    Fix? Rename the file. This is done by right-clicking the file in your package or project explorer and selecting Refactor->Rename. You may need to clean your project after, but beware of the dreaded "import android.R" that may creep in.

    Good luck! -scott

    0 讨论(0)
  • 2020-12-11 04:55

    You need to make sure you import R. If your main package is com.example try importing "com.example.R" at the top of your files. For some reason eclipse does not do this for you.

    0 讨论(0)
提交回复
热议问题