I've search on here how to do it but I found sources from 2015 and the layout of Android Studio has changed since then. Where is the R file in Android Studio.enter image description here
How to find the R file in Android Studio 2020?
3.6k Views Asked by Bahaa Hmiedan AtThere are 5 best solutions below

R is Generated class in android and after you build your project this class will be create first build your project after that 4 times click on shift button on your keyboard. in new windows search 'R' class and in list find R.java class that's it

According to the docs; for improving the efficiency and build performance of gradle; the plugin now generates the JAR directly instead of generating intermediate R.java
files. In previous gradle plugins; R.java
would be generated for all the dependencies which you include in your app.gradle
file or external dependencies. These R classes were then compiled alongside the app's other java classes; which would create overheads and unnecessary or redundant compilations thereby slowing down the build performances of the application.
The Android Gradle plugin simplifies the compile classpath by generating only one R class for each library module in your project and sharing those R classes with other module dependencies.
The new optimization that is done may improve build performance for projects with many dependencies significantly, and improve the indexing speed also thus requiring faster and efficient builds in android studio.
When I tried to decompile the R jar
file which is located at your_project_directory\app\build\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug
using jd-gui; I was able to get the R.class
implementation containing id's of the Views
which I used for my application just like we would get in earlier versions of gradle.(which confirmed the linking.)
NOTE:
If your application is using AAPT2; then you can generate the R.java
and Proguard rules intermediate files. To get the command syntax; you can use options from aapt2 link
command.

The new Android Gradle Plugin generates the corresponding bytecode directly and does not make the intermediate R.java file.
Source
https://android-developers.googleblog.com/2020/02/android-studio-36.html
See Where is the R.java file in Android Studio?.
Project
view and findapp/outputs/apk/debug/app-name-debug.apk
.classes*.dex
files.Expand the package and find
R$id
(see picture 1).Right-click and press
Show Bytecode
.You will see a file where you can find needed id. Click inside the file, press Ctrl+F and paste id.