I m trying to learn Android Development and have some experience with Java. When a smple code is generated with Android Studio, it generates a class called MainActivity that extends from AppCompatActivity . In same class There is reference to R.layout.activity_main etc.When I say go to declaration of R , it takes to activity_main.xml . I think it should take to the base class where R is actually declared. May I know what is the java class type for R and which of the class it is declared in Android SDK
Asked
Active
Viewed 201 times
2
-
1you are missing Android basics. Go through some tutorial about the R class\ – Vladyslav Matviienko Nov 02 '18 at 08:41
-
check this https://stackoverflow.com/questions/15993572/what-r-java-file-actually-does-and-how – karan Nov 02 '18 at 08:47
-
Possible duplicate of [What is the class R in Android?](https://stackoverflow.com/questions/4953077/what-is-the-class-r-in-android) – Mikhail Olshanski Nov 02 '18 at 08:51
2 Answers
0
android aapt (now its aapt2 from android plugin 3.0 ) tool auto generates R.java class for your all resources.You could use R.java class to access all your resources from apps.
R.java is final class and you can't modify the class as it is autogenerated when you build your project.

Ramesh Yankati
- 1,197
- 9
- 13
0
R.java
is the dynamically generated class, created during build process to dynamically identify all assets (from strings to android widgets to layouts), for usage in java classes in Android app. Note this R.java
is Android specific (though you may be able to duplicate it for other platforms, its very convenient), so it doesn't have much to do with Java language constructs. Take a look here, for more details.
Answer Taken From: Here

Ümañg ßürmån
- 9,695
- 4
- 24
- 41