Android: Can you add activities to the Instant App module?

后端 未结 1 2078
执笔经年
执笔经年 2020-12-21 23:46

I\'m trying to create an Instant App, but wanted to know if I can add an activity to my Instant App module.

When creating an Instant App module, the android studio w

1条回答
  •  时光取名叫无心
    2020-12-22 00:24

    You can't add code to a module using the com.android.instantapp plugin.

    From the documentation:

    When you build your instant app, this module takes all of the features and creates Instant App APKs. It does not hold any code or resources; it contains only a build.gradle file and has the com.android.instantapp plugin applied to it.

    Given that all code can be shared through com.android.feature modules with it's not necessary to have code in the instantapp module.

    For reusability it is recommended to have little to no code in modules that apply the com.android.application plugin, but to add dependencies to the projects like this:

    dependencies {
        implementation project(':features:hello')
        implementation project(':features:bye')
        implementation project(':features:base')
    }
    

    And host code within modules that rely on the com.android.feature plugin.

    These will be compiled like this:

    |    depending module     |     compiled to     |
    |-----------------------------------------------|
    | com.android.application | application apk     |
    | com.android.instantapp  | apk for each module | <- then packed into a zip file
    

    0 讨论(0)
提交回复
热议问题