首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >工具:替换Android清单中的不替换

工具:替换Android清单中的不替换
EN

Stack Overflow用户
提问于 2014-09-23 02:50:28
回答 8查看 214.3K关注 0票数 169

我正在使用一个具有许多不同库依赖项的gradle项目,并使用新的清单合并。在我的<application />标签中,我将其设置为:

代码语言:javascript
复制
<application tools:replace="android:icon, android:label, android:theme, android:name"
    android:name="com.example.myapp.MyApplcation"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/application_name"
    android:logo="@drawable/logo_ab"
    android:theme="@style/AppTheme"
    >
....
</application>

然而,我收到了这个错误:

代码语言:javascript
复制
/android/MyApp/app/src/main/AndroidManifest.xml:29:9        Error:
Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:29:9
is also present at {Library Name} value=(@drawable/app_icon)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:26:5 to override

/android/MyApp/app/src/main/AndroidManifest.xml:30:9 Error:
Attribute application@label value=(@string/application_name) from AndroidManifest.xml:30:9
is also present at {Library Name} value=(@string/app_name)
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:26:5 to override

/android/MyApp/app/src/main/AndroidManifest.xml:27:9 Error:
Attribute application@name value=(com.example.myapp.MyApplication) from AndroidManifest.xml:27:9
is also present at {Another Library}

Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml:26:5 to override

/android/MyApp/app/src/main/AndroidManifest.xml:32:9 Error:
Attribute application@theme value=(@style/AppTheme) from AndroidManifest.xml:32:9
is also present at {Library Name} value=(@style/AppTheme)
Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:26:5 to override
EN

回答 8

Stack Overflow用户

发布于 2014-12-08 23:13:16

像这样声明您的清单标头

代码语言:javascript
复制
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourpackage"
    xmlns:tools="http://schemas.android.com/tools">

然后,您可以将以下属性添加到应用程序标记中:

代码语言:javascript
复制
<application
    tools:replace="icon, label" ../>

例如,我需要替换图标和标签。祝好运!

票数 276
EN

Stack Overflow用户

发布于 2015-12-04 09:02:56

尝试在gradle文件中重新排序依赖项。我不得不将有问题的库从列表的底部移到顶部,然后它就起作用了。

票数 38
EN

Stack Overflow用户

发布于 2017-10-24 12:48:40

对我来说,遗漏的部分是:

代码语言:javascript
复制
xmlns:tools="http://schemas.android.com/tools"

例如:

代码语言:javascript
复制
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
    package="com.your.appid">
票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25981156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档