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

后端 未结 24 1162
孤城傲影
孤城傲影 2020-11-22 02:30

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:

  • S
相关标签:
24条回答
  • 2020-11-22 03:20

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

    0 讨论(0)
  • 2020-11-22 03:21

    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.

    0 讨论(0)
  • 2020-11-22 03:21

    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.

    0 讨论(0)
  • 2020-11-22 03:21

    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);
        }
    
    
    }
    
    0 讨论(0)
  • 2020-11-22 03:22

    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.

    0 讨论(0)
  • 2020-11-22 03:22

    Make sure that all these are in upto date.

    0 讨论(0)
提交回复
热议问题