Where is the R.java file in Android Studio? Can someone please help with this? I already tried google for the answer but can't find any solution.
It will be located under app\build\generated\source\r directory.
Android R. java is an auto-generated file by aapt (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/ directory. If you create any component in the activity_main. xml file, id for the corresponding component is automatically created in this file.
R file contains IDs for all the resources in the res folder of your project and also some additional IDs that you define on your own (in the layouts, for example). The IDs are needed for the Android resource management system to retrieve the files from the APK.
Based on the new stable release of Android Studio (3.6) we have:
So, now to find your generated resource classes you need the following steps:
1) Open your project.
2) Go to your module build path.
3) Open the outputs/apk/debug/app-name-debug.apk file.
4) Choose your classes.dex file.
5) Look at the down placed area and go to your full package path.
6) You can see all bytecoded resource classes. So, scroll down to what you are looking for.
7) Expand the resource class you need to proceed (for example, let it be R.id)
8) Go to you id's.
That's it.
UPDATE:
If you would like to see actual id integer number you should follows steps below:
1) By (7) Go to the resource class you need to proceed and right click to show the context menu
2) Choose "Show Bytecode" to see the flexible dialog "DEX Byte Code for R$id", for example, for id class
3) Scroll down to the actual id to look its number
Although the current Android Gradle Plugin doesn't generate a R.java
anymore you can still inspect the corresponding class file (see Sergey V.`s answer).
However, if you (like probably in most cases) just want to look up the generated IDs for your resources, there is an easier way:
In the project pane on the left hand side switch from Android to Project view using the drop-down at the top. Then navigate to app/build/intermediates/runtime_symbol_list/<insert build type here>/R.txt
. This file lists all IDs generated by AGP during the build process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With