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?
-
Do you really need different minSdk? Instant apps do not require 23. See https://stackoverflow.com/q/44774512/407058. – philo Feb 14 '18 at 12:59
-
1I asked lower sdk in order to work for the installable app and the instant app under single project with the same featured structure. – DiRiNoiD Feb 14 '18 at 13:17
-
Sure. But when you say "instant app supports min 23", it sounds like you believe that instant apps feature plugin requires min 23. That is not the case. I think 16 is possible. If not, then @JohnOreilly is on the right track. But check out https://github.com/googlesamples/android-instant-apps/tree/master/configuration-apks, which improves on that answer a bit by using missingDimensionStrategy to avoid creating unnecessary variants. – philo Feb 14 '18 at 13:31
3 Answers
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,457
- 2
- 21
- 38
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"
)

- 10,000
- 4
- 41
- 63
-
can you check url https://developer.android.com/studio/build/build-variants.html for more info. – Prags Feb 14 '18 at 10:31
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.

- 801
- 7
- 17