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

错误信息

在项目中引用第三方的库时,比如https://github.com/LuckSiege/PictureSelector图片选择的库,出现以下错误

Manifest merger failed : Attribute application@theme value=(@style/ActivityTheme) from AndroidManifest.xml:82:9-45
    is also present at [com.github.LuckSiege.PictureSelector:picture_library:v2.2.3] AndroidManifest.xml:11:18-49 value=(@style/AppTheme).
    Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:77:5-419:19 to override.

错误描述&解决方案

  • 我们的主项目中默认会定义了 android:theme="" ,当我们引入的第三方库中也定义了这种标签的时候,二者合并失败就会出现此问题。
  • 解决办法是在 AndroidMainifest<application> 标签中添加tools:replace="android:theme"
  • 对于tools:replace="android:icon"一样。如果同时存在则以隔开
    tools:replace="android:theme,android:icon"

详细代码


<application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        tools:replace="android:theme"
        android:theme="@style/ActivityTheme">
        <activity android:name=".business.basic.ui.WelcomeActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容