Android Studio 4.0.1 找不到R.java 2020.09.08

看以往的教材中R.java都是在项目的appuildgeneratedsource debug包名下的

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

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项目,发现generatedsource目录下不存在 debug,在文件管理其中搜索有关R的文件发现R.java变为了R.txt

并且R.txt在D:AndroidHelloWorldappuildintermediates untime_symbol_listdebug目录下

stackoverflow上面有这样的操作:

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

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

原文地址:https://www.cnblogs.com/linkchen/p/13633568.html