美文网首页
AndroidStudio出现tools:replace="an

AndroidStudio出现tools:replace="an

作者: 全球顶尖伪极客 | 来源:发表于2018-07-03 15:54 被阅读0次

错误信息

在项目中引用第三方的库时,比如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>

相关文章

网友评论

      本文标题:AndroidStudio出现tools:replace="an

      本文链接:https://www.haomeiwen.com/subject/ecqjuftx.html