2017-05-27 54 views
1

我已经使用API​​ 25(Nougat)制作了一个使用Android Studio的简单应用程序,但现在我想为API 21(棒棒糖)创建一个APK,因此我已将项目结构中的“编译SDK版本”更改为API 21,但Android Studio给了我以下错误:为什么我无法编译使用较低API的android studio项目?

D:\AndroidStudioProject\ArduinoData\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml 
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. 
Error:(34) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. 
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. 
Error:(34) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. 
D:\AndroidStudioProject\ArduinoData\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml 
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'. 
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'. 
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'. 
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'. 
Error:Execution failed for task ':app:processDebugResources'. 
> com.android.ide.common.process.ProcessException: Failed to execute aapt 

我知道这可能是一个图形不兼容,但我不知道如何解决它,你有什么想法解决它?

styles.xml

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat"> 
     <!-- Customize your theme here. 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item>--> 
    </style> 

</resources> 

build.grandle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 21 
    buildToolsVersion '21.1.2' 
    defaultConfig { 
     applicationId "com.acerbisgianluca.arduinodata" 
     minSdkVersion 21 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    productFlavors { 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_6 
     targetCompatibility JavaVersion.VERSION_1_6 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:21.0.2' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.google.firebase:firebase-messaging:10.0.1' 
    compile 'com.google.firebase:firebase-ads:10.0.1' 
    compile 'com.google.firebase:firebase-core:10.0.1' 
    testCompile 'junit:junit:4.12' 
} 
apply plugin: 'com.google.gms.google-services' 
+0

我的新答案解决了您的问题吗? –

+0

我的问题还没有解决 – Gianluca

+0

请用下面的答案更新你的代码。 –

回答

0

我想你已经在你的应用程序级的build.gradle文件书面compileSdkVersion 21和25 targetSdkVersion。 targetSdkVersion不应高于compileSdkVersion。你正确地做到了,但你因此未将buildToolsVersion21.1.2

更改appcompat库版本添加更新buildToolsVersionappcompatlibrary版本的API等级21

更改为21.0.2在应用级的build.gradle文件。您必须根据API级别21更新库版本。

我认为这将解决您的问题。

+0

只有这一行**