AndroidStudio出现tools:replace="android:theme"问题

最近项目开发使用模块开发,在开发过程中遇到下面问题,所以顺手记录一下。

错误信息

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@theme value=(@style/AppTheme) from AndroidManifest.xml:35:9-40
    is also present at [TC_Hospital_Patient:zybwenzhen:unspecified] AndroidManifest.xml:17:9-47 value=(@style/AppWenzhenTheme).
    Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:29:5-44:19 to override.

错误提示中已经给出了解决方案,就在最后一句话中描述了。Suggestion: add ‘tools:replace=”android:theme”’ to element at AndroidManifest.xml:29:5-44:19 to override.

错误描述

其实出现这个错误的原因是,我们的主工程中已经使用了android:theme=”@style/AppTheme”,而在module中也使用到了android:theme=”@style/AppTheme”,所以编辑器在运行程序的时候会去合并,但是合并失败就会报此错误。

解决方案

解决方法就是在主工程的AndroidManifest.xml中application标签中添加tools:replace=”android:theme”代码,不过首先的去声明命名空间,在manifest标签中声明命名空间,xmlns:tools=”http://schemas.android.com/tools”

类似问题

其中还有icon,label等都可能出现上面问题,解决类似,在Manifest.xml的application标签下添加tools:replace=”android:icon, android:theme”(多个属性用,隔开)


  • 其他方案

在build.gradle根标签上加上useOldManifestMerger true 这方法有的版本不适用

  • 6
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值