2

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

Neil
  • 365
  • 5
  • 8

2 Answers2

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