使用动态功能和构建样式时出现合并错误 [英] Manifest Merger Error when using Dynamic Features and Build Flavors

查看:145
本文介绍了使用动态功能和构建样式时出现合并错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用动态功能模块,可以在 AndroidManifest.xml 中定义应预先安装的模块:

With dynamic-feature-modules it is possible to define in the AndroidManifest.xml wheter a module should come preinstalled:

<dist:module
    ...
    dist:onDemand="false"
    dist:title="@string/title_shop">
    ....
</dist:module>

还是不:

<dist:module
    ...
    dist:onDemand="true"
    dist:title="@string/title_shop">
    ....
</dist:module>

我的项目中有两种构建风格.该模块应该以一种口味预装,而不能以另一种口味预装.

I have two build flavors in my project. The module should be preinstalled in one flavor but not in the other.

想法是在 main 源代码集中设置以下默认 AndroidManifest.xml :

The idea is to have this default AndroidManifest.xml in the main source set:

<dist:module
    ...
    dist:onDemand="true"
    dist:title="@string/title_shop">
    ....
</dist:module>

对于应该预装模块的构建版本-我创建一个 AndroidManifest.xml 文件,该文件将覆盖该 dist:onDemand 属性改为 false :

For build flavors that should have the module preinstalled - I create a AndroidManifest.xml file that overrides that dist:onDemand property to false:

<dist:module
    ...
    tools:replace="dist:onDemand"
    dist:onDemand="false"
    ...
</dist:module>

不幸的是,这不起作用.清单合并失败,并出现以下错误:

Unfortunately, this does not work. The Manifest Merger fails with the following errors:

合并错误:错误:在属性dist:onDemand的行:11处指定了tools:replace,但没有指定新值车间清单,第10行错误:验证失败,退出了车间清单.

Merging Errors: Error: tools:replace specified at line:11 for attribute dist:onDemand, but no new value specified shop manifest, line 10 Error: Validation failed, exiting shop manifest.

有人知道这里出了什么问题吗?

Does anyone have an idea what's wrong here?

推荐答案

此答案对我有用.这个想法是有两个AndroidManifest.xml副本,除了

This answer worked for me. The idea is to have two copies of the AndroidManifest.xml, which are identical except

<dist:module
    ...
    tools:node="replace"
    dist:onDemand="false">
    ...
</dist:module>

其中替换了整个元素 .

这篇关于使用动态功能和构建样式时出现合并错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆