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

假如想象 提交于 2019-11-29 17:20:13

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