Zhou Hao Zhou Hao - 25 days ago 8x
Android Question

Failed to run my android application because a level 21 app generate level 23 files

Here my build.gradle:

apply plugin: 'com.android.application'

android {
signingConfigs {

compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.mycompany"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"

buildTypes {
release {
debuggable false
signingConfig signingConfigs.config
minifyEnabled true
zipAlignEnabled true
proguardFile 'proguard-rules.pro'
debug {
debuggable true
signingConfig signingConfigs.config

dependencies {
compile 'com.facebook.android:facebook-android-sdk:3+'
compile 'com.android.support:support-v4:+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services:+'
compile 'com.github.codechimp-org.apprater:library:1.0.+'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile files('libs/disklrucache-2.0.2.jar')
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/socialauth-4.2.jar')
compile files('libs/socialauth-android.jar')

I can compile my source code without problem but get the following error message when I try to run:


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:Execution
failed for task ':project:processReleaseResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'/Users/myname/.android-sdk/build-tools/21.1.2/aapt'' finished with
non-zero exit value 1

I really don't understand. My compiledSdkVersion and targetSdkVersion is 21 and I even don't have a file called values-v23. Why got this error? Can anybody help? Thanks.

Edit 1:

@Gabriele Mariotti's answer solved this problem. But here comes another problem.

Error:Execution failed for task '::transformResourcesWithMergeJavaResForRelease'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/org.brickred/socialauth/pom.properties
File1: /Users/xxxxxx/libs/socialauth-4.2.jar
File2: /Users/xxxxxx/libs/socialauth-4.2.jar

What could be the reason? I checkd there is of course only one socialauth-4.2.jar in my libs folder.


Since you are using

compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'

you are using the latest versions which has a dependency with support libraries v24.

You have to use compileSdkVersion 24

In general it is not a good idea to use this kind of dependencies (+) because you will not be able to reproduce the build in the future (since the dependencies will change)