问题
my android project min sdk level is 16. I want to turn it into instant app but I need to maintain min sdk level but instant app supports min 23. I tried to set different api levels for the installable and instant app in the same project and tried to override them but I wasn't able to do. So is there any way to work in same project with installable app and instant app with different min sdk levels?
回答1:
Another way to do this so that the instant app APKs have the desired minSdkVersion
is with this:
App (com.android.instant.application) manifest:
<uses-sdk tools:overrideLibrary="com.example.feature"/>
App (com.android.instant.application) gradle
:
minSdkVersion rootProject.minSdk
Feature (com.android.instant.feature) gradle
:
minSdkVersion rootProject.minSdkInstant
This allowed me to build
- Installed app with
minSdk
- Instant app APKs with
minSdkInstant
The only recommended way is to use flavors.
Besides the tools:overrideLibrary
method, there are no other ways to do this.
The APKs are generated from the feature plugin and not from the instant App plugin.
Can you check android-instant-apps/configuration-apks/features/build.gradle and this SO Question
回答2:
The only way I've been able to do this is by using different product flavors. For example:
instant {
dimension "delivery"
minSdkVersion 23
}
installed {
dimension "delivery"
}
Note you can have multiple dimensions defined (for example I have flavorDimensions "app_type", "delivery"
)
回答3:
You can also refer this AIA minSdkVersion bug for details on your query, with recommended way to use flavors.
Quoting the details shared on the link:
Another way to do this so that the instant app APKs have the desired minSdkVersion is with this:
App (com.android.application) manifest:
App (com.android.application) gradle: minSdkVersion rootProject.minSdk
Feature (com.android.feature) gradle: minSdkVersion rootProject.minSdkInstant
This allowed me to build - installed app with minSdk - instant app APKs with minSdkInstant
Also refer this link for information on flavor dimensions.
来源:https://stackoverflow.com/questions/48781647/instant-app-installable-app-with-different-min-sdk-levels