I am trying to run the APK on API 22 device after updating compileSdkVersion to N but unable to do so.
compileSdkVersion \'android-N\'
buildTool
I found a solution that work but before that a little bit of history. What I did was trying to have different variants of my app and each variant would have its own compileSdkVersion
Those are snippets from my build.gradle
First attempt (compileSdkVersion is variant specific): Let you install the app on API level >= ANDROID-N only
//compileSdkVersion 'android-N'
buildToolsVersion '24.0.0 rc1'
productFlavors {
dev {
compileSdkVersion 23
targetSdkVersion 23
}
experimental {
compileSdkVersion 'android-N'
minSdkVersion 'N'
targetSdkVersion 'N'
}
}
Second attempt (compileSdkVersion still variant specific but I removed experimental variant): Let you install the app on API Level < ANDROID-N only
//compileSdkVersion 'android-N'
buildToolsVersion '24.0.0 rc1'
productFlavors {
dev {
compileSdkVersion 23
targetSdkVersion 23
}
/*
experimental {
compileSdkVersion 'android-N'
minSdkVersion 'N'
targetSdkVersion 'N'
}
*/
}
Third attempt (compileSdkVersion still variant specific but experimental is defined before dev)
//compileSdkVersion 'android-N'
buildToolsVersion '24.0.0 rc1'
productFlavors {
experimental {
compileSdkVersion 'android-N'
minSdkVersion 'N'
targetSdkVersion 'N'
}
dev {
compileSdkVersion 23
targetSdkVersion 23
}
}
At my big surprise this one worked ! I don't know why but it does. All you have to do is define your Android-N only variant before any other variant, click Build Variants in Android Studio and select the one you want to compile.
I am going to file an issue in the Android-N bug tracker and update this answer when I get more info.