我对 gradle 版本控制设置非常困惑。我发现some information关于这个构建系统,但没有任何地方写过有关版本控制的详细信息。你能解释一下这些选项的含义吗?
compileSdkVersion
buildToolsVersion
minSdkVersion
targetSdkVersion
minSdkVersion
是最明显的,因为它意味着我们想要支持的最小 API,例如14(Android >= 4.0)。
targetSdkVersion
:
This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version.
不太明白。
我的情况是支持 API 15 的设备。正确的设置是什么?
我在某处读到目标应该尽可能最高,Android Studio 也告诉我这一点,但是当我设置它并尝试在 Nexus 5 上运行时,我得到:
Failure [INSTALL_FAILED_OLDER_SDK]
我的build.gradle
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "my.package.name"
minSdkVersion 14
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
最佳答案
根据官方文档: http://developer.android.com/preview/setup-sdk.html#createProject 如果您想尝试新功能,您应该使用这些值:
compileSdkVersion is set to 'android-L'
minSdkVersion is set to 'L'
targetSdkVersion is set to 'L'
这是失败的原因[INSTALL_FAILED_OLDER_SDK]。
如果您不需要 android-L,我建议使用这些值:
defaultConfig {
applicationId "my.package.name"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
也就是说,这里描述了一个非官方的解决方法(无论如何我建议你不要使用它)
关于Android Gradle 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24972283/