Skip to content

Android Studio 4.0.1 找不到 R.java

博客园链接

看以往的教材中 R.java 都是在项目的\app\build\generated\source\r\debug\包名下的

通常 AS 会自动在项目的 R.java 中创建代表项目中资源的资源 ID,大致格式如下

R.java
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
public final class R
{
    public static final class layout
    {
        public static final int activity_main = 0x7f040017;
    }

    public static final class mipmap
    {
        public static final int ic_launcher = 0x7f030000;
    }

    public static final class string
    {
        public static final int app_name = 0x7f0b0011;
        public static final int hello_world = 0x7f0b0012;
    }
}

结果今天在使用 AS4.0.1 新建 Helloworld 项目,发现\generated\source 目录下不存在\r\debug\,在文件管理其中搜索有关 R 的文件发现 R.java 变为了 R.txt

1

并且 R.txt 在 D:\Android\HelloWorld\app\build\intermediates\runtime_symbol_list\debug 目录下

stackoverflow 上面有这样的操作:

https://stackoverflow.com/questions/28522144/where-is-the-r-java-file-in-android-studio

2

再右键就能 show bytecode 就能看见了

3

Comments