软件编程
位置:首页>> 软件编程>> Android编程>> Android Studio报:“Attribute application@theme or @ icon ”问题的解决

Android Studio报:“Attribute application@theme or @ icon ”问题的解决

作者:咔咔和拉拉  发布时间:2023-11-07 09:49:18 

标签:android,studio,报错attribute

前言

Android Studio是Google开发的一款面向Android开发者的IDE,支持Windows、Mac、Linux等操作系统,基于流行的Java语言集成开发环境IntelliJ搭建而成。

发现问题

最近在做项目的时候需要导入第三方库时碰到这个问题


Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@theme value=(@style/AppTheme.NoActionBar) from
AndroidManifest.xml:21:9-52is also present at [MyChaass:mymusic:unspecified]

AndroidManifest.xml:17:9-40 value=(@style/AppTheme).Suggestion: add'tools:replace="android:theme"'
to <application> element at AndroidManifest.xml:15:5-37:19 to override.

原因是我们的主项目中默认会定义了 android:icon="" ,当我们引入的第三方库中也定义
了这种标签的时候,二者合并失败就会出现此问题。

解决方法

解决办法是在 <application> 标签中 添加 tools:replace="android:icon" .

首先要在 <manifest> 标签中增加一个 tools 的命名空间 :


xmlns:tools=http://schemas.android.com/tools

与此相同的问题还有 theme ,解决办法同样是增加 tools:replace="android:theme" ,

不过当二者都合并失败时,中间应该用","隔开 :


tools:replace="android:icon,android:theme"

manifest文件:


<application
 android:allowBackup="true"
 android:icon="@mipmap/christ_icon"
 android:label="@string/app_name"
 android:supportsRtl="true"
 android:name=".App"
 tools:replace="android:icon,android:theme" //加这句即可
 android:theme="@style/AppTheme.NoActionBar">
</application>

增 加 以上代码 即可解决问题。

来源:http://www.jianshu.com/p/b6c763d1b98f

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com