Android Studio 中的 R.java 文件在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28522144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where is the R.java file in Android Studio?
提问by TheChessDoctor
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.
Android Studio 中的 R.java 文件在哪里?有人可以帮忙吗?我已经尝试谷歌寻找答案,但找不到任何解决方案。
回答by Belal Khan
It is inside app\build\generated\source\r
folder
它在app\build\generated\source\r
文件夹内
回答by alijandro
R.java
is the generated file by ADT or Android studio. It will be located under app\build\generated\source\r
directory.
R.java
是ADT或Android studio生成的文件。它将位于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
回答by Shubham Soni
Project/app/build/generated/source/r/debug/com.android.'projectname'/R.java
项目/app/build/generated/source/r/debug/com.android.'projectname'/R.java
回答by Niamatullah Bakhshi
回答by Engr Saeed Anwar
I am using Android Studio 2.2.3 , the R.java file is shown in the picture below. Goto in the left upper side there is a selecting list ,
我使用的是 Android Studio 2.2.3 ,R.java 文件如下图所示。转到左上角有一个选择列表,
- select [package]
- Open "App Folder"
- com.example.saeedanwar.myapplication;
- r
- 选择【套餐】
- 打开“应用文件夹”
- com.example.saeedanwar.myapplication;
- r
回答by OulinaArt
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
回答by CoolMind
回答by Bad0
--The R.Java that contains your xml layouts and views id's in Android Studio 3.5.3 -- Project/app/build/generated/not_namespaced_r_class_sources/debug/r/com/"your package"/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
回答by Sergey V.
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.apkfile.
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. So, scroll down to what you are looking for.
6) 您可以看到所有字节编码的资源类。因此,向下滚动到您要查找的内容。
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 以查看其编号
回答by ubuntudroid
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 Androidto Projectview 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 AGPduring the build process.
在左侧的项目窗格中,使用顶部的下拉菜单从Android切换到项目视图。然后导航到app/build/intermediates/runtime_symbol_list/<insert build type here>/R.txt
. 该文件列出了 AGP在构建过程中生成的所有 ID。