When developing for Instant Apps the use of Configuration APKs (https://developer.android.com/topic/instant-apps/guides/config-splits.html) offers useful option for cutting
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
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.