Android Studio 一直在使用 sdk 23 而我不希望它使用

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

我的应用程序有点问题。这是我几个月前构建的应用程序,运行良好。

昨天,我有一个改变要做,成功了,试图编译它..我有这个错误:

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.1.2\aapt.exe'' finished with non-zero exit value 1

我的 build.gradle 包含以下内容: android{ 编译SDK版本21 buildToolsVersion '21.1.2'

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

我不想升级到 SDK 23(类似线程中最常见的答案),我想了解这里出了什么问题,以及为什么我从不使用该死的 sdk 时会出现此错误。

有线索吗?

我认为原因是 Android Studio 的自动更新。如果您从 Sdk 管理器下载了 Build-tools rev.23,请尝试将其删除,然后清理并重建项目。确保 compileSdkVersionbuildToolsVersiontargetSdkVersioncom.android.support:appcompat 匹配相同的版本。

更新: 指的是更新的 build.gradle,问题在于使用动态依赖项(+ 符号)这将强制 gradle获取最新的库版本。根据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)