【问题标题】:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'检索项目的父项时出错:找不到与给定名称“android:TextAppearance.Material.Inverse”匹配的资源
【发布时间】:2015-11-06 18:09:03
【问题描述】:

我正在尝试在我的应用程序中实现 GCM。我已将 'com.google.android.gms:play-services:8.1.0' 添加到我的 app.gradle 文件中,但出现以下错误:

Error:(13) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(15) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(21) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(28) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.

这是我的 App.gradle:

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.google.gms.google-services'

def AAVersion = '2.7'
repositories {
    maven {
        url "https://mint.splunk.com/gradle/"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.squareup:otto:1.3.4'
    compile 'com.j256.ormlite:ormlite-android:4.47'
    compile 'javax.persistence:persistence-api:1.0.2'
    compile 'org.apache.httpcomponents:httpmime:4.2.5'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'commons-io:commons-io:2.2'
    compile 'com.google.guava:guava:15.0'
    compile 'joda-time:joda-time:2.2'
    compile 'com.squareup:tape:1.1.1'
    apt "com.googlecode.androidannotations:androidannotations:$AAVersion"
    compile "com.googlecode.androidannotations:androidannotations-api:$AAVersion"
    provided 'org.projectlombok:lombok:1.14.4'
    apt "org.projectlombok:lombok:1.14.4"
    compile "com.splunk.mint:mint:4.3.0"
    compile 'me.grantland:autofittextview:0.2.+'
}

android {
    compileSdkVersion 19
    buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example"
    minSdkVersion 16
    targetSdkVersion 19
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
packagingOptions {
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'LICENSE.txt'
}
}
apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName "com.example"
    }
}

这是我的 project.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'com.google.gms:google-services:1.4.0-beta3'

    }
}


allprojects {
    repositories {
        jcenter()
    }
}

【问题讨论】:

  • 我找不到任何导致此问题的 Google Play 服务文档,但这通常是没有使用正确的 api 版本编译的情况。尝试将 compileSdkVersion 和 targetSdkVersion 都设置为 22,因为您使用 22.0.1 作为构建工具。
  • 您必须检查 com.google.android.gms:play-services:8.1.0 的依赖关系。您将找到支持库 v22。它们需要编译 API 22。

标签: android google-cloud-messaging google-play-services android-gradle-plugin


【解决方案1】:

API 21 中引入了“Material Design”。您正在针对 API 19 进行编译:

compileSdkVersion 19

targetSdkVersion 19

试试这个:

compileSdkVersion 21

targetSdkVersion 21

(从技术上讲,您不必针对与目标相同的 API 进行编译,但这样做是不明智的……它可能会导致一些非常奇怪且难以识别的错误。)

【讨论】:

  • 谢谢,我将 play-services8.1.0 更改为 7.5.0 并且成功了。另外,我没有导入整个play-services,而是只导入了我需要的东西(play-services-maps:7.5.0play-services-gcm:7.5.0
猜你喜欢
  • 2017-10-27
  • 2014-06-04
  • 2017-02-10
  • 2017-06-27
  • 2017-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-27
相关资源
最近更新 更多