Matt Kime
Matt Kime

Reputation: 73

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:

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

        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.

What I've tried:

  1. Cleaning the project.

  2. Rebuilding the project.

  3. Relaunching Android Studio.

  4. Invalidating the cache and restarting.

  5. Checking XML files for obvious (to my beginner's eyes) or identified errors.

  6. Changing the dependencies in the app gradle from

    dependencies { compile fileTree(dir: 'libs', include: ['*.jar'])

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

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

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

    compile 'com.squareup.picasso:picasso:2.4.+'

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

to specific version references.

Upvotes: 1

Views: 603

Answers (1)

Emmanuelguther
Emmanuelguther

Reputation: 1059

Try this (I had a similar problem, not the same), and run.

Add this in your proguard-rules.pro:

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

Upvotes: 1

Related Questions