2016-09-17 69 views
0

我想知道爲什麼我在首位得到這個錯誤,如何解決和匹配爲什麼它有效?非常感謝您的幫助。錯誤:項(72)錯誤檢索父:沒有資源發現在給定的名字「TextAppearance.AppCompat.Display1」

我的搖籃文件如下:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.2" 

    packagingOptions { 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'LICENSE.txt' 
    } 

    defaultConfig { 
     applicationId "com.mycompany.myapp" 
     minSdkVersion 18 
     targetSdkVersion 24 
     versionCode 4 
     versionName "4.0" 

     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 

    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     debug { 
      applicationIdSuffix '.d' 
      versionNameSuffix '-debug' 
     } 
    } 
} 

ext { 
    supportLibraryVersion = '24.2.1' 
    junitVersion = '4.12' 
    mockitoVersion = '1.10.19' 
    hamcrestVersion = '1.3' 
    espressoVersion = '2.2.2' 
    runnerVersion = '0.5' 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile "com.android.support:appcompat-v7:$supportLibraryVersion" 
    compile "com.android.support:support-v4:$supportLibraryVersion" 

    testCompile "junit:junit:$junitVersion" 
    testCompile "org.mockito:mockito-all:$mockitoVersion" 
    testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion" 

    androidTestCompile "com.android.support.test:runner:$runnerVersion" 
    androidTestCompile "com.android.support.test:rules:$runnerVersion" 
    androidTestCompile "com.android.support.test.espresso:espresso-core:$espressoVersion" 
    androidTestCompile "com.android.support.test.espresso:espresso-intents:$espressoVersion" 
    androidTestCompile "com.android.support.test.espresso:espresso-contrib:$espressoVersion" 
    //androidTestCompile "com.android.support.test.espresso:espresso-web:$espressoVersion" 
    //androidTestCompile "com.android.support.test.espresso:espresso-idling-resource:$espressoVersion" 
} 

configurations.all { 
    resolutionStrategy.force "com.android.support:support-v4:$supportLibraryVersion" 
    resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion" 
    //resolutionStrategy.force "com.android.support:recyclerview-v7:$supportLibraryVersion" 
} 

configurations.compile.dependencies.each { compileDependency -> 
    println "Excluding compile dependency: ${compileDependency.getName()}" 
    configurations.androidTestCompile.dependencies.each { androidTestCompileDependency -> 
     configurations.androidTestCompile.exclude module: "${compileDependency.getName()}" 
    } 
} 

做在Android Studio IDE中的生成時,我得到的錯誤是如下:

Error:(72) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'. 
Error:(75) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'. 
Error:(89) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'. 
Error:(97, 5) No resource found that matches the given name: attr 'textAllCaps'. 
Error:(102, 5) No resource found that matches the given name: attr 'elevation'. 
Error:(113, 5) No resource found that matches the given name: attr 'backgroundTint'. 
Error:(113, 5) No resource found that matches the given name: attr 'elevation'. 
+0

@ cricket_007你說得對。你可以請你的想法作爲答案,以便我可以接受它。請解釋您是如何從Android文檔中進行這種推理的,所以我想了一下您的想法。提前致謝! – karthiks

回答

1

我認爲你缺少支持Android設計庫

嘗試添加該

compile "com.android.support:design:$supportLibraryVersion" 

原因是那些是你缺少的主題。雖然我無法證明那些實際上已經包含在設計庫中,但它們是有意義的,它們來自哪裏。

而且,如果確實包含該依賴關係,則這些行實際上並不是必需的。

compile "com.android.support:appcompat-v7:$supportLibraryVersion" 
compile "com.android.support:support-v4:$supportLibraryVersion" 
+0

你是對的。也就是說,我的Espresso測試失敗,除非我添加'compile「com.android.support:support-v4:$supportLibraryVersion」 '。 Wierd: -/ – karthiks

+0

我認爲這是因爲帶有'configurations.all'的底部部分以及後面的那個帶有排除部分的部分...... Support Design庫過渡地包含了這兩個,所以我不確定爲什麼會出現錯誤 –

相關問題