Java 清单合并失败错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28095703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Manifest merger failed error
提问by James King
I am in the process of moving my current projects huge application into Android Studio and Gradle. I am currently stuck on the following issue:
我正在将我当前的项目大型应用程序转移到 Android Studio 和 Gradle 中。我目前被困在以下问题上:
Error:(87, 9) Execution failed for task ':App:processDebugManifest'.
> Manifest merger failed : Attribute application@label value=(@string/app_label) from AndroidManifest.xml:87:9
is also present at ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name)
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:82:5 to override
I have tried adding the following attributes to the main AndroidManifest.xml
file:
我尝试将以下属性添加到主AndroidManifest.xml
文件中:
tools:replace="android:label, *App Name*"
tools:replace="android:label, @string/app_label"
tools:replace="android:label"
None of these attribute definitions works. What am I doing wrong?
这些属性定义都不起作用。我究竟做错了什么?
采纳答案by Kayvan N
Give this a try:
试试这个:
Add this to <manifest/>
将此添加到 <manifest/>
xmlns:tools="http://schemas.android.com/tools"
Add this to <application/>
将此添加到 <application/>
tools:node="replace"
Based on this, it should override all the elements. "Replace the lower priority declaration with the annotated one."
基于此,它应该覆盖所有元素。“用带注释的声明替换较低优先级的声明。”
回答by CJBS
Background
背景
When the manifest files are being merged, there is a conflict with the label
attribute.
合并清单文件时,与该label
属性存在冲突。
In general, there are three typesof manifest files that need to be merged into a single resulting app manifest, here in priority order :
通常,需要将三种类型的清单文件合并到一个生成的应用清单中,这里按优先级排序:
- Product flavors and build types specific manifest files.
- Main manifest file for the application.
- Library manifest files.
- 产品风格和构建类型特定的清单文件。
- 应用程序的主清单文件。
- 库清单文件。
Resolutions
决议
The conflict can be resolved in one of two ways:-
冲突可以通过以下两种方式之一解决:-
Remove the conflicting label
删除冲突的标签
Remove the conflicting attribute from the library (or lower-level) manifest file.
从库(或较低级别)清单文件中删除冲突的属性。
In this case, the ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name)
has a @string/app_name
value defined that's different from that in the main application. So if it's not required, then remove it -- simply remove the android:label="@string/app_name"
from the library file's AndroidManifest.xml
file.
在这种情况下,定义ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name)
的@string/app_name
值与主应用程序中的值不同。因此,如果不需要,则将其删除 - 只需android:label="@string/app_name"
从库文件的AndroidManifest.xml
文件中删除。
Add an attribute to allow an automatic resolution to the conflict
添加属性以允许自动解决冲突
There are several special attribute markers(in the tools namespace) that may be used to express a specific decision for how to resolve conflicts.
有几个特殊的属性标记(在工具命名空间中)可用于表达如何解决冲突的特定决定。
In this case, to explicitly cause the main app's android:label
to override any other (e.g. library file) application labels, add the xmlns:tools="http://schemas.android.com/tools"
definition to the <manifest>
node, and tools:replace="label"
to the <application>
node.
在这种情况下,明确地引起主应用程序的android:label
重写任何其他(如库文件)应用程序标签中,添加xmlns:tools="http://schemas.android.com/tools"
定义为<manifest>
节点,tools:replace="label"
到<application>
节点。
Here is an example - use this in the main application's AndroidManifest.xml
file:
这是一个示例 - 在主应用程序的AndroidManifest.xml
文件中使用它:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myapp"
xmlns:tools="http://schemas.android.com/tools">
<application
android:label="@string/app_name"
tools:replace="label"/>
</manifest>
This approach would also work with any other conflicting attributes; for example if the icon
attribute was also in conflict, it could be changed to tools:replace="label, icon"
.
这种方法也适用于任何其他冲突的属性;例如,如果该icon
属性也存在冲突,则可以将其更改为tools:replace="label, icon"
.
回答by dm78
If you were fortunate, as I was, you can manually fix the problem with a hacky work-around.
如果你像我一样幸运的话,你可以通过一个 hacky work-around 手动修复这个问题。
AAR files are just .zip files with an .aar extension. In my case, I unzipped the .aar, removed the offending android:label
from the library's AndroidManifest.xml
, and then rearchived the remaining files with a .aar extension and everything seems to work perfectly with the new .aar.
AAR 文件只是带有 .aar 扩展名的 .zip 文件。就我而言,我解压缩了 .aar,android:label
从库的AndroidManifest.xml
.
FYI, this appears to be a known bug in the android gradle plugin.
回答by Kimmi Dhingra
I was also facing same issues, and after lot of research found the soultion
我也面临同样的问题,经过大量研究发现了灵魂
- your min sdk version should be same as of the modules you are using eg: your module min sdk version is 14 and your app min sdk version is 9 It should be same.
- If build version of your app and modules not same. Again it should same
- 您的最小 sdk 版本应该与您正在使用的模块相同,例如:您的模块最小 sdk 版本是 14,您的应用程序最小 sdk 版本是 9 它应该是相同的。
- 如果您的应用程序和模块的构建版本不同。再次它应该相同
In short, your app build.gradle file and manifest should have same configurations
简而言之,您的应用 build.gradle 文件和清单应该具有相同的配置
- There's no duplicacy like same permissions added in manifest file twice, same activity mention twice
- If you have delete any activity from your project, delete it from your manifest file as well
- Sometimes its becuase of label, icon etc tag of manifest file a) add the xmlns:tools line in the manifest tag b) add tools:replace= or tools:ignore=in the application tag Example
- 没有重复,例如在清单文件中两次添加相同的权限,两次提及相同的活动
- 如果您从项目中删除了任何活动,也请从清单文件中删除它
- 有时是因为清单文件的标签、图标等标签 a) 在清单标签中添加 xmlns:tools 行 b) 在应用程序标签中添加 tools:replace= 或 tools:ignore= 示例
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.slinfy.ikharelimiteduk"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="1"
android:versionName="1.0" >
<application
tools:replace="icon, label"
android:label="myApp"
android:name="com.example.MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.AppCompat" >
</application>
</manifest>
By considering these points in mind, you will get rid of this manifest merger failed issue Check my post: This issue is due to issue in Manifest file or build.gradle file. You can check my post https://wordpress.com/post/dhingrakimmi.wordpress.com/23
通过考虑这些要点,您将摆脱这个清单合并失败问题检查我的帖子:这个问题是由于清单文件或 build.gradle 文件中的问题。您可以查看我的帖子 https://wordpress.com/post/dhinrakimmi.wordpress.com/23
回答by stefan K
I fixed same issue. Solution for me:
我修复了同样的问题。对我的解决方案:
- add the
xmlns:tools="http://schemas.android.com/tools"
line in the manifest tag - add
tools:replace=..
in the manifest tag - move
android:label=...
in the manifest tag
xmlns:tools="http://schemas.android.com/tools"
在清单标记中添加该行- 添加
tools:replace=..
清单标签 android:label=...
在清单标签中移动
回答by itzo
I just removed
我刚删除
android:label="@string/app_name
android:label="@string/app_name
from the manifest file
and it worked!
从manifest file
,它的工作!