What is R: There is nothing very mysterious about R. It's just a class that has many static subclasses, open it in an eclipse and watch (its under Gen /).
Each member of this class is one of two things: 1) static finite classes, or 2) static finite integers that are unique to other members of their class.
Why this is so mysterious: It is easy to confuse, because R is automatically generated by ant. Its mysterious, because you do not have to โtouchโ it manually (of course, you can, but your changes are automatically erased during regeneration). It is also cryptic because sometimes eclipse automatically imports androids standard R file (as described in the answers above)
Why is it always the first that cannot be resolved: R exactly follows the rules of Java classes and packages, nothing special about how R acts with respect to imports. R will be automatically placed in the package specified in the package entry in the manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="package.which.will.contain.R.and.probably.the.main.package.in.the.application" android:versionName="8.6.2011" android:versionCode="1"> <uses-sdk android:minSdkVersion="13" />
To find out which package belongs to your R file, simply open the gen / folder folder in eclipse (package view). You will see one package specified there, it will have the name that you specified in the manifest. Try deleting it, it will return if all your resources follow the correct naming rules, and all your xml files follow the correct xml rules, and if the assembly is automatically included in eclipse.
The key to understanding the R file is understanding that it is in the same package as other classes, even if it is in a different directory, and then other files belonging to your โmainโ package. Once you understand this and understand the syntax and names of the resource files, troubleshooting with R is easy.
tjb Mar 28 2018-12-12T00: 00Z
source share