badkarma badkarma - 3 months ago 17
Android Question

Android Studio keeps using sdk 23 while I don't want it to

I have a little issue with an app. This is an app that I built several months ago, and it was working fine.

Yesterday, I had a change to do, made it, tried to compile it.. And I have this error :

D:\android\MyApp\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:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\xxxx\AppData\Local\Android\Sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1


My build.gradle contains the follow :
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'

defaultConfig {
applicationId "xxxx"
minSdkVersion 9
targetSdkVersion 21
versionCode 21
versionName "2.5"
}
}


I do NOT want to upgrade to SDK 23 (most common answer in similar threads), I want to understand what's wrong here, and why I have this error while I never use that god damn sdk.

Any clue ?

Answer

I think that the reason is auto-update of Android Studio. If you have downloaded Build-tools rev.23 from the Sdk manager, try to delete it, then clean and rebuild project. Make sure that compileSdkVersion, buildToolsVersion, targetSdkVersion and com.android.support:appcompat match the same version.

Update: referring to updated build.gradle, the problem lies in using dynamic dependencies (+ sign) which will force gradle to grab the latest library version. According to documentation:

(...) Using dynamic dependencies (for example, palette-v7:23.0.+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a library version (for example, palette-v7:24.2.0)