Instant App Installable App with Different Min Sdk Levels

吃可爱长大的小学妹 提交于 2019-12-20 02:53:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!