[英]Where is the R.java file in Android Studio?
Where is the R.java file in Android Studio? Android Studio 中的 R.java 文件在哪里? Can someone please help with this?有人可以帮忙吗? I already tried google for the answer but can't find any solution.我已经尝试谷歌寻找答案,但找不到任何解决方案。
Based on the new stable release of Android Studio (3.6) we have:基于Android Studio (3.6)的新稳定版本,我们有:
So, now to find your generated resource classes you need the following steps:因此,现在要查找生成的资源类,您需要执行以下步骤:
1) Open your project. 1)打开你的项目。
2) Go to your module build path. 2)转到您的模块构建路径。
3) Open the outputs/apk/debug/app-name-debug.apk file. 3) 打开outputs/apk/debug/app-name-debug.apk文件。
4) Choose your classes.dex file. 4) 选择您的 classes.dex 文件。
5) Look at the down placed area and go to your full package path. 5) 查看向下放置的区域并转到您的完整包装路径。
6) You can see all bytecoded resource classes. 6) 您可以看到所有字节编码的资源类。 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) 7)展开你需要进行的资源类(比如,让它是R.id)
8) Go to you id's. 8)去你的身份证。
That's it.就是这样。
UPDATE:更新:
If you would like to see actual id integer number you should follows steps below:如果您想查看实际的 id 整数,您应该按照以下步骤操作:
1) By (7) Go to the resource class you need to proceed and right click to show the context menu 1)通过(7)转到您需要继续的资源类并右键单击以显示上下文菜单
2) Choose "Show Bytecode" to see the flexible dialog "DEX Byte Code for R$id", for example, for id class 2) 选择“Show Bytecode”可以看到灵活的对话框“DEX Byte Code for R$id”,例如id class
3) Scroll down to the actual id to look its number 3) 向下滚动到实际 ID 以查看其编号
I use Android Studio 3.3.2我使用 Android Studio 3.3.2
\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\android\support\constraint\R.java
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).尽管当前的 Android Gradle 插件不再生成R.java
,但您仍然可以检查相应的类文件(请参阅 Sergey V. 的回答)。
However, if you (like probably in most cases) just want to look up the generated IDs for your resources, there is an easier way:但是,如果您(可能在大多数情况下)只想为您的资源查找生成的 ID,则有一种更简单的方法:
In the project pane on the left hand side switch from Android to Project view using the drop-down at the top.在左侧的项目窗格中,使用顶部的下拉菜单从Android切换到项目视图。 Then navigate to app/build/intermediates/runtime_symbol_list/<insert build type here>/R.txt
.然后导航到app/build/intermediates/runtime_symbol_list/<insert build type here>/R.txt
。 This file lists all IDs generated by AGP during the build process.该文件列出了 AGP在构建过程中生成的所有 ID 。
As noted above, "The new Android Gradle Plugin generates the corresponding bytecode directly and does not make the intermediate R.java file".如上所述,“新的Android Gradle Plugin直接生成对应的字节码,不制作中间R.java文件”。
Using the ubuntudroid solution you can find an id
also this way.使用ubuntudroid 解决方案,您也可以通过这种方式找到id
。 Find R.txt
and copy absolute path.找到R.txt
并复制绝对路径。 Project > app > build > intermediates > runtime_symbol_list > debug > R.txt.项目 > 应用程序 > 构建 > 中间体 > runtime_symbol_list > 调试 > R.txt。 Then right click and select Copy Path...
, 1. Absolute Path Ctrl+Shift+C
.然后右键单击并选择Copy Path...
, 1. Absolute Path Ctrl+Shift+C
。
This way you will obtain a path to R.txt
, for instance, "C:\\Users\\user\\AndroidStudioProjects\\your_project\\app\\build\\intermediates\\runtime_symbol_list\\debug\\R.txt".通过这种方式,您将获得R.txt
的路径,例如“C:\\Users\\user\\AndroidStudioProjects\\your_project\\app\\build\\intermediates\\runtime_symbol_list\\debug\\R.txt”。 Copy the path without R.txt
to a text file for future references, for example, with Notepad++.将不带R.txt
的路径复制到文本文件以供将来参考,例如,使用 Notepad++。
Press Ctrl + Shift + F to find in directory.按Ctrl + Shift + F在目录中查找。 Insert an id
and the path.插入一个id
和路径。
== Old answer == == 旧答案 ==
Change a project view from Android
to Project
or Project Files
.将项目视图从Android
更改为Project
或Project Files
。 Find one of these two files.找到这两个文件之一。
Then you can revert back to Android
view.然后您可以恢复到Android
视图。
R.java
is the generated file by ADT or Android studio. R.java
是 ADT 或 Android studio 生成的文件。 It will be located under app\\build\\generated\\source\\r
directory.它将位于app\\build\\generated\\source\\r
目录下。
./app/build/generated/source/r/debug/android/support/v7/appcompat/R.java
./app/build/generated/source/r/debug/your/packagename/name/R.java
I am using Android Studio 2.2.3 , the R.java file is shown in the picture below.我使用的是 Android Studio 2.2.3 ,R.java 文件如下图所示。 Goto in the left upper side there is a selecting list ,转到左上角有一个选择列表,
它在app\\build\\generated\\source\\r
文件夹中
If you're using Mac or Linux, try the following command line on your terminal:如果您使用的是 Mac 或 Linux,请在终端上尝试以下命令行:
find . -name "R.*"
It will print something like:它将打印如下内容:
./app/build/intermediaries/runtime_symbol_list/debug/R.txt
./app/build/intermediaries/compile_and_runtime_not_namespaced_r_class_jar/debug/R.jar
项目/app/build/generated/source/r/debug/com.android.'projectname'/R.java
--在Android Studio 3.5.3中包含你的xml布局和视图ID的R.Java -- Project/app/build/generated/not_namespaced_r_class_sources/debug/r/com/"your package"/R.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.