You can specify a different lower minSdkVersion for your application module if you use tools:overrideLibrary
Please see How do I use tools:overrideLibrary in a build.gradle file?
This is how I did it:
app/build.gradle
android {
defaultConfig {
minSdkVersion 17
}
}
app’s manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.app" xmlns:tools="http://schemas.android.com/tools" >
<uses-sdk tools:overrideLibrary="com.package,com.package.feature"/>
</manifest>
You will need to add all the package names where you wish to override their minSdkVersion
. You will know which ones to add by looking at the error:
Manifest merger failed ...
AndroidManifest.xml as the library might be using APIs not available
in 17 Suggestion: use a compatible library with a minSdk of at most
17,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.package.feature" to force usage (may lead to runtime failures)
base and feature/build.gradle
android {
defaultConfig {
minSdkVersion 21
}
}
Test it by building the installed/instant APKs, then analyzing then for the minSdkVersion
value. The installed should be at 17, and your base/feature APKs will still be on 21.