编译多个sdk版本

时间:2018-05-25 19:24:36

标签: android android-studio

我已经安装了SDK 16(android 4.1),20(android 4.4)和27(android 8.1)并且代码配置了以下规格

compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    applicationId "com.test.android"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 25
    versionName "2.6.7"
    vectorDrawables.useSupportLibrary = true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

我想在Android 4.1上安装时确保应用程序正常。这足以将compileSdkVersion修改为16吗?或者我必须相应地更改buildToolsVersion

1 个答案:

答案 0 :(得分:1)

目标和编译级别应尽可能高,您必须这样做,因为Google将来会拒绝低目标。

在开发时,IDE中会将不兼容的代码标记为红色警告。通常会出现以下警告:"代码XX需要更新的版本(22),而minSdk需要16" 这些错误会使您的应用与旧版本的版本不兼容。