简体   繁体   English

R.java在Android Studio中生成错误

[英]R.java generates incorrectly in Android Studio

In working on my current project, I am attempting to make a basic browser for Flickr, and I have been trying to use the recycler_view as follows: 在处理当前项目时,我正在尝试为Flickr创建基本的浏览器,并且一直在尝试使用recycler_view,如下所示:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    activateToolbar();

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    ProcessPhotos processPhotos = new ProcessPhotos("android, lollipop", true);
    processPhotos.execute();
}

The project did not list any errors until I attempted to run it, at which time Android Studio identifies an error in R.java line 2655, where the file repeatedly generates as 在我尝试运行该项目之前,该项目没有列出任何错误,这时Android Studio在R.java第2655行中标识了一个错误,该文件重复生成为

        public static final int recycler view=0x7f0c006b;

which is obviously a problem because the correct name for it is recycler_view, and the lack of an underscore prevents the whole deal from launching. 这显然是一个问题,因为其正确名称是recycler_view,并且缺少下划线会阻止整个交易的启动。

What I've tried: 我尝试过的

  1. Cleaning the project. 清理项目。

  2. Rebuilding the project. 重建项目。

  3. Relaunching Android Studio. 重新启动Android Studio。

  4. Invalidating the cache and restarting. 使缓存无效并重新启动。

  5. Checking XML files for obvious (to my beginner's eyes) or identified errors. 检查XML文件是否存在明显的错误(在我的初学者看来)或发现的错误。

  6. Changing the dependencies in the app gradle from 从更改应用程序gradle中的依赖项

    dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) 依赖项{编译fileTree(dir:'libs',包括:['* .jar'])

    compile 'com.android.support:recyclerview-v7:23.1.+' 编译'com.android.support:recyclerview-v7:23.1.+'

    compile 'com.android.support:appcompat-v7:23.1.+' 编译'com.android.support:appcompat-v7:23.1.+'

    compile 'com.android.support:design:23.1.+' 编译'com.android.support:design:23.1.+'

    compile 'com.squareup.picasso:picasso:2.4.+' 编译'com.squareup.picasso:picasso:2.4。+'

    compile 'com.android.support:cardview-v7:23.1.+' 编译'com.android.support:cardview-v7:23.1.+'

to specific version references. 特定版本参考。

Try this (I had a similar problem, not the same), and run. 试试这个(我有类似的问题,不一样),然后运行。

Add this in your proguard-rules.pro : 将其添加到您的proguard-rules.pro

-keep class android.support.v7.** { *; }
-dontwarn android.support.v7.**
-dontshrink

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM