Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the R.java file in Android Studio?

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.

like image 685
TheChessDoctor Avatar asked Feb 15 '15 01:02

TheChessDoctor


People also ask

How do I find the R file in Android?

It will be located under app\build\generated\source\r directory.

What is the use of R Java file in Android Studio?

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.

What does R Java file contain in Android?

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.


2 Answers

Based on the new stable release of Android Studio (3.6) we have: enter image description here

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.

enter image description here

7) Expand the resource class you need to proceed (for example, let it be R.id)

enter image description here

8) Go to you id's.

enter image description here

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

enter image description here

3) Scroll down to the actual id to look its number

enter image description here

like image 160
Sergey V. Avatar answered Sep 21 '22 05:09

Sergey V.


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.

like image 36
ubuntudroid Avatar answered Sep 23 '22 05:09

ubuntudroid