Shortly after the Google I/O keynote and the consecutive talks about Android M features, I started playing around with the new SDK functions, e.g., runtime permissions. For that it is necessary to set the compileSdkVersion
as well as the targetSdkVersion
to android-mnc
.
When running the project on a Nexus 5 with the Android M Developer Preview installed, Android Studio installs the application and it works fine on the device.
If I set the minSdkVersion
to, e.g., 10 to test it on a 2.3.6 device or to 21 to test it on a 5.0 device, it still works on the M-Nexus5 but not on the aforementioned devices with lower-than-M API versions.
apply plugin: 'com.android.application'
android {
buildToolsVersion "22.0.1"
compileSdkVersion 'android-MNC'
defaultConfig {
applicationId "de.FOOBAR.permtestproject"
minSdkVersion 10
targetSdkVersion 21
versionCode 23
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
}
As you can see in the following screenshot, my level-21 device is shown as incompatible even though I set the minSdkVersion to 10 and not to the claimed level of 22.
Lowering the targetSdkVersion
to 21
doesn’t make a difference. Changing the compileSdkVersion
is not an option as the permission request calls have not been available in pre-M(NC) SDKs.
Trying to run the application on a pre-M device always fails with the error INSTALL_FAILED_OLDER_SDK
.
Quoting myself: