0

我試圖在我的應用程序中實現GCM。我已經添加了'com.google.android.gms:play-services:8.1.0'我app.gradle文件,我發現了以下錯誤:檢索項目的父項時出錯:未找到與給定名稱匹配的資源'android:TextAppearance.Material.Inverse'

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() 
    } 
} 
+2

我無法找到導致此問題的Google Play服務的任何文檔,但這通常是不使用正確的api版本進行編譯的情況。嘗試將compileSdkVersion和targetSdkVersion設置爲22,因爲您使用的是構建工具22.0.1。 –

+1

您必須檢查com.google.android.gms:play-services:8.1.0的依賴關係。你會找到支持庫v22。 他們需要編譯API 22。 –

回答

1

「材料設計」,在API 21中引入正在編譯針對API 19:

compileSdkVersion 19 

targetSdkVersion 19 

試試這個:

compileSdkVersion 21 

targetSdkVersion 21 

(你在技術上沒有進行編譯相同的API作爲目標,但它是不明智的這樣做...它可能會導致一些非常奇怪和難以識別錯誤。)

+0

謝謝,我將'play-services'從'8.1.0'改爲'7.5.0',並且工作正常。另外,我不是導入整個'play-services',而是導入我需要的東西('play-services-maps:7.5.0'和'play-services-gcm:7.5.0') – mhorgan

相關問題