Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

I've always programmed Android with Eclipse and decided to start migrating to Android Studio. I 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 two 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?

I already tried what was suggested in Stack Overflow question appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable', but it didn't work.

like image 907
Vini.g.fer Avatar asked Aug 18 '15 14:08

Vini.g.fer


5 Answers

Your compile SDK version must match the support library's major version.

Since you are using version 23 of the support library, you need to compile against version 23 of the Android SDK.

Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.

like image 197
Bryan Herbst Avatar answered Oct 22 '22 18:10

Bryan Herbst


This happens because after updates Android 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.

like image 44
Sourav Nanda Avatar answered Oct 22 '22 18:10

Sourav Nanda


When you update your Android Studio, it uses API version 23 by default, which is the main reason for its occurrence. So,

At first, check your AppCompat version in build.gradle(Module:app) That is,

Enter image description here

If after changing to 23 there occurs an 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 the SDK Manager Button and open the dialog.

Enter image description here

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

if not, then download that first. After completing the download, click Apply.

Enter image description here

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

  1. Click the app from the 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 rebuild your project.

Then your error will be gone.

like image 117
Ravikant Paudel Avatar answered Oct 22 '22 17:10

Ravikant Paudel


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.

like image 69
Pelanes Avatar answered Oct 22 '22 19:10

Pelanes


I agree with the previous answer. 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.

like image 36
Stucky Avatar answered Oct 22 '22 19:10

Stucky