最近项目开发使用模块开发,在开发过程中遇到下面问题,所以顺手记录一下。
错误提示中已经给出了解决方案,就在最后一句话中描述了。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 这方法有的版本不适用