Upgrade project to Android M compatible
I know this can be a tricky question for some people, but I've been searching this article all day and trying to figure out how to set up a file build.gradle
in my Android project.
I am updating some APIs and preparing them for Android M. Now everything is fine. However, I'm confused in minSdkversion
, targetSdkversion
, complieSdkVersion
.
My current setup
android {
compileSdkVersion 'android-MNC' //this was 21
buildToolsVersion "22.0.1"
defaultConfig {
...
minSdkVersion 11
targetSdkVersion 'MNC' //this was 21
...
}
...
}
As you can see from the comments, my application was executed and targeted API21 before, and now I change it to MNC
to cover the whole range from api11
to MNC
.
These are my test cases,
Android M device (API22) --- OK
Android 5.1.1 device (API22) --- error and FAILED_OLDER_SDK
If I change my setting to
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
...
minSdkVersion 11
targetSdkVersion 21
...
}
Test cases,
Android M device (API22) --- OK
Android 5.1.1 device (API22) --- OK
Android 4.3.1 device (API18) --- OK // Why is this ok?
if a device with API18 can execute project against 21, then why Android 5.1.1 (API22) was unable to execute project against MNC?
source to share