Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23
up vote 341 down vote favorite
56

I've always programed android with Eclipse and decided to start migrating to Android Studio. Decided to use the same SDK I already had for eclipse, then:

  • Started a new project
  • Set minimum SDK 4.0 (API Level 14)
  • Choose Blank Activity option
  • Used Default names for Activity Name and Layout Name
  • Hit Finish

After a few seconds Gradle finishes the build, and it throws me 2 errors with the following messages in file Teste4\app\build\intermediates/exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v23\values-v23.xml

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

Under File -> Project Structure -> Modules: app (left column) -> Properties tab, I have the following versions set up:

  • "Compile Sdk Version": Android 5.1 (API Level 22)
  • "Build Tools Version": 23.0.2

What should I do in order to fix this?

Already tried what was suggested here, but didn't work appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable'

Thanks!



StackOverflow

Agree with the above. Your compile SDK version must match the support library. Here is what I did.

1) You can go to SDK Manager and under SDK Platform, install the Android 5.X with API level 23.
2) Under Project Structure, change Compile Sdk Version to API 23, and Build Tools Version to 23.0.0

Then it should build without problem.



This happens because after updates your studio uses api version 23 by default.

The following worked for me:

Press CTRL + SHIFT + ALT + S to get to the project structure page. Go to the properties tab and change 23.0.0 to 22.0.1 (or equivalent to what you were using earlier) in the build tool area and rebuild your project.

If that doesn't work, go to gradle:app and then

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'

Edit v7:23.0.0 to v7:22.2.1 as shown above and sync gradle this will definitely work.



If you are getting errors even after downloading newest SDK and Android Studio here is what I did:

  1. Download the most recent SDK
  2. Open file-Project structure (ctrl+alt+shift+S)
  3. In modules select app
  4. In properties tab..change compile sdk version to api 23 Android 6.0 marshmallow (latest)

Hope it helps someone so that he won't suffer like I did for these couple of days.



As pointed out by Tanis.7x, the support library version (23) does not match the targetSdkVersion (22)

You can fix this by doing the following:

In the build.grade file of your app module, change the following line of code

compile 'com.android.support:appcompat-v7:23.0.0'

To

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

This will use the latest version of the appcompat version that is compatible with SdkVersion 22.



When you updates your android studio, it uses api version 23 by default, Which is the main reason of its occurance. So,

At First Check your app Compact version in built.graidle(Module:app) That is, enter image description here

if after changing to 23 there occurs error then Just download

Compile Sdk Version to API 23, and Build Tools Version to 23.0.0

from SDK Manager. if already downloaded then

1. Go to SDK Manager and 
2. Under Project Structure, change Compile Sdk Version to API 23, and Build Tools Version to 23.0.0

Click SDK Manager Button and open the Dialog.

enter image description here

Click SDK Platform and check if Android 6.0 is downloded or not.

if not then download that first. After Completing Download click Apply.

enter image description here

Now you need to apply changes to your project from setting. Then Press Ctrl+Alt+Shit+S to open setting

  1. Click app from list.
  2. Click properties
  3. Change your Compile SDK Version to API 23
  4. Change your Build Tools Version to 23.0.0

enter image description here

Don't forget to rebuilt your project.

Then your error will be gone. if problem occur msg me. Hope this will help .



I found the solution, Problem started when I updated sdk, after that I used different buildToolsVersion ('22.0.1') and I was using different support library like compile 'com.android.support:appcompat-v7:23.0.0', showing you in image below

enter image description here

This was raising problem of "android.widget.Material..." Then I used same version for support library like compile 'com.android.support:appcompat-v7:22.0.1' and its DONE. (Showing you in below screenshot)

enter image description here



You should compile your project with latest version so update & install your SDK. Sync your project with sync project with Gradle file Button. You can also continue with the existing version but check its installed properly & sync your project if needed.

enter image description here

it may help.



Another solution : navigate to

\sdk\extras\android\m2repository\com\android\support\appcompat-v7\23.x.x

open .aar file with 7-zip or winrar , in res folder remove values-23 folder and save changes .



android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'

defaultConfig {
    applicationId ""
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'

}



on module: app (Gradle)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.namepack.nameappxxxxx"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

project: nameAppXXXX (Gradle)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'

    }
}

allprojects {
    repositories {
        jcenter()
    }
}

and edit your activity of AppCompatActivity to for example Activity:

package com.namepack.nameappxxxxx;


import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

public class NameClass extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
    }


}


This issue is raised because now the compile SDK version must match the Android Support library's major version.

In my case i have the Android Support Library version 23, so i had to compile against the Android SDK version 23, and I had to change this in my build.gradle file:

enter image description here

Well some of you will need to install the SDK, Android 6.0 (API 23)

enter image description here

and don´t forget to Sync project with gradle files



You need to set compileSdkVersion to 23.

Since API 23 Android removed the deprecated Apache Http packages, so if you use them for server requests, you'll need to add useLibrary 'org.apache.http.legacy' to build.gradle as stated in this link:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    ...

    //only if you use Apache packages
    useLibrary 'org.apache.http.legacy'
}


I got the same problems. I solved my problem by updating gradle.build for each sub-module to latest compiler version.



If you've tried to change target to a previous GooglePlayServices or AppCompatv7 version and it doesn't work, check if you have any project-libraries dependency, this project will be targeting the latest version of any of these libraries. It happened to me with the Google Maps Utils Library project:

replace:

compile 'com.google.android.gms:play-services:+'

to

compile 'com.google.android.gms:play-services:8.3.0'

Then you can continue full targeting API 22

If it still doesn't compile, sometimes is useful to set compileSdkVersion API to 23 and targetSdkVersion to 22.



SDK Manager

Make sure that all these are in upto date.



Upgrade Android Studio.

I had this issue with Android Studio 1.3.1 and none of the other answers worked for me, but after updating to 1.5.1 there were no problems.