简体   繁体   English

如何为Android Instant App设置package / applicationId?

[英]How to set the package/applicationId for android instant app?

My project structure contains a base feature module, an installed app module (with free and paid flavors) and an instant app module(only one flavor - free). 我的项目结构包含一个基本功能模块,一个已安装的应用程序模块(带有免费和付费版本)和一个即时应用程序模块(仅一个版本-免费)。 It seems like the package name for the instant app is coming from the base feature module's manifest. 即时应用程序的软件包名称似乎来自基本功能模块的清单。

Why does not the applicationId field in build.gradle of instant app overwrite the package field in the manifest as it does for the installed app? 为什么即时应用程序的build.gradle中的applicationId字段不像对已安装的应用程序那样覆盖清单中的package字段?

The same behaviour is also observed in the hello instant app sample. hello Instant应用程序示例中也观察到相同的行为

The base feature module needs to have an application reference to the application module in its dependencies. 基本功能模块需要在其依赖项中具有对application程序模块的application引用。 This allows the base feature to pull in the applicationId from the app module instead of using the one defined in its AndroidManifest.xml . 这允许基本功能从应用程序模块中提取applicationId ,而不使用其AndroidManifest.xml定义的功能。

For example your base feature's build.gradle would look like: 例如,基本功能的build.gradle如下所示:

dependencies {
   feature project(':feature1')
   feature project(':feature2')
   application project(':app')
   ...
}

According to the documentation this will build all the flavours (paid & free) and pull in the applicationId for each one. 根据文档,这将构建所有样式(收费和免费),并为每种样式引入applicationId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM