简体   繁体   English

Android Studio Gradle 图标错误,清单合并

[英]Android studio Gradle icon error, Manifest Merger

I keep seeing this message and not sure how to solve it for good.我一直看到这条消息,但不知道如何永久解决它。

Error:(43, 9) Attribute application@icon value=(@drawable/new_app_icon) from AndroidManifest.xml:43:9
    is also present at com.github.erizet.signala:signala-longpolling:0.20:7:18 value=(@drawable/ic_launcher)
    Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:40:5 to override
:OpenBook:processDebugManifest FAILED
Error:Execution failed for task ':OpenBook:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

Tried adding android:replace="android:icon" to my manifest even with my icon.即使使用我的图标,也尝试将android:replace="android:icon"到我的清单中。

I tried deleting the android:icon="@drawable/ic_launcher from the library but it keeps coming back when i build because its imported from maven我尝试从库中删除android:icon="@drawable/ic_launcher但它在我构建时不断返回,因为它是从 maven 导入的

Any ideas ?有任何想法吗 ?

It seems to be the fault of the mainfest Merger tool for gradle.这似乎是 gradle 的主要合并工具的错。

http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

Solved it by adding to my manifest tag xmlns:tools="http://schemas.android.com/tools"通过添加到我的清单标签xmlns:tools="http://schemas.android.com/tools"解决了这个问题

Then added tools:replace="android:icon,android:theme" to the application tag然后将tools:replace="android:icon,android:theme"到应用程序标签

This tells the merger to use my manifest icon and theme and not of other libraries这告诉合并使用我的清单图标和主题,而不是其他库

Hope it helps thanks希望有帮助谢谢

I have same issue , I fix it like this by adding xmlns:tools="http://schemas.android.com/tools" to the top of mainfest file , and add tools:replace="android:icon" to be look like我有同样的问题,我通过将xmlns:tools="http://schemas.android.com/tools"到 mainfest 文件的顶部来修复它,并添加tools:replace="android:icon"来查看喜欢

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"  // add tools line here 
    package="yourpackage">


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:replace="android:icon"> ///add this line 

.....

</application>

</manifest>

i have same error , just this code solve my problem , i want to share with you :我有同样的错误,只是这段代码解决了我的问题,我想与您分享:

in Manifest.xml :Manifest.xml

  • add this code in top of your xml file :将此代码添加到您的 xml 文件顶部:

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

  • Then added :然后补充说:

    tools:replace="android:icon,android:theme,android:label,android:name" to the application tag tools:replace="android:icon,android:theme,android:label,android:name"到应用程序标签

The answer of shimi_tap is enough. shimi_tap 的回答就够了。 What to be remembered is that choosing only what you need.需要记住的是,只选择你需要的。 Choose from {icon, name, theme, label}.从{图标、名称、主题、标签}中选择。 I added tools:replace="android:icon,android:theme" , it does not work.我添加了tools:replace="android:icon,android:theme" ,它不起作用。 I added tools:replace="android:icon,android:theme,android:label,android:name" , it does not work.我添加了tools:replace="android:icon,android:theme,android:label,android:name" ,它不起作用。 It works when I added tools:replace="android:icon,android:theme,android:label" .当我添加tools:replace="android:icon,android:theme,android:label"时它起作用了。 So find out what the conflict exactly is in your manifest files.因此,找出清单文件中的冲突到底是什么。

只需将xmlns:tools="http://schemas.android.com/tools"到您的清单标签,然后您需要android:icon="@mipmap/ic_launcher"之前添加tools:replace="android:icon" android:icon="@mipmap/ic_launcher" .

当您的应用程序的 minSdk 高于任何库的 minSdk 时,也会发生此错误。

app's minSdk >= libraries minSdk

GOT THE SOLUTION AFTER ALOT OF TIME GOOGLING经过长时间的谷歌搜索后得到了解决方案

just get your ic_launcher and paste it in your drawables folder,只需获取您的ic_launcher并将其粘贴到您的 drawables 文件夹中,

Go to your manifest and change android:icon="@drawable/ic_launcher"转到您的清单并更改 android:icon="@drawable/ic_launcher"

Clean your project and rebuild清理你的项目并重建

Hope it helps you希望对你有帮助

I had this problem changing the icon from drawable to mipmap.我在将图标从 drawable 更改为 mipmap 时遇到了这个问题。

I only missed the line我只是错过了线路

tools:replace="android:icon"

in the manifest.在清单中。

For some reason android studio doesn't like calling app icon from drawable folder.出于某种原因,android studio 不喜欢从可绘制文件夹中调用应用程序图标。 So in that case I created mipmap resource directory under res folder.所以在这种情况下,我在 res 文件夹下创建了 mipmap 资源目录。

Right click res folder > new > android resource directory > resource type: mipmap and now drop any icon in there then reference that into manifest file.右键单击 res 文件夹 > 新建 > android 资源目录 > 资源类型:mipmap ,现在将任何图标放入其中,然后将其引用到清单文件中。 Sharing this since this method worked for me.分享这个,因为这种方法对我有用。

android:icon:@drawable/ic_launcher" android:icon:@drawable/ic_launcher"

to

android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"

If nothing of that work, close Android Studio.如果这些都不起作用,请关闭 Android Studio。 Go on app/src/main, open the file AndroidManifest.xml in a text editor (like sublime), remove/replace the erros lines, save and reopen android studio.转到 app/src/main,在文本编辑器(如 sublime)中打开文件 AndroidManifest.xml,删除/替换错误行,保存并重新打开 android studio。

When an attribute value contains a placeholder (see format below), the manifest merger will swap this placeholder value with an injected value.当一个属性值包含一个占位符(见下面的格式)时,清单合并会用一个注入的值交换这个占位符值。 Injected values are specified in the build.gradle.注入值在 build.gradle 中指定。 The syntax for placeholder values is ${name} since @ is reserved for links.占位符值的语法是 ${name},因为 @ 是为链接保留的。 After the last file merging occurred, and before the resulting merged android manifest file is written out, all values with a placeholder will be swapped with injected values.在最后一次文件合并发生之后,在写出合并后的 android 清单文件之前,所有带有占位符的值都将与注入的值交换。 A build breakage will be generated if a variable name is unknown.如果变量名称未知,将生成构建损坏。

from http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Build-error来自http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Build-error

Shimi_tap's answer is the right way to fix the problem. Shimi_tap 的答案是解决问题的正确方法。 If you want to use old merger tool you can add this to build.gradle file如果你想使用旧的合并工具,你可以将它添加到 build.gradle 文件中

android { useOldManifestMerger true } android { useOldManifestMerger true }

For me, this issue occurred after updating Google Play Services.对我来说,这个问题是在更新 Google Play 服务后发生的。 One of the libraries I was using incorporated this library using the "+" in its gradel reference, like我使用的库之一在它的 Gradel 参考中使用“+”合并了这个库,比如

compile 'com.google.android.gms:play-services:+'

This created an issue because the min version targeted by that library was less than what was targeted by the current version of Google Play Services.这产生了一个问题,因为该库所针对的最小版本小于当前版本的 Google Play 服务所针对的版本。 I found this by simply looking in the logs.我通过简单地查看日志发现了这一点。

In your .gradle change MinSDK, for example:在您的.gradle更改 MinSDK,例如:

  • build.gradle (Module: app) build.gradle (模块:app)
    • before: minSdkVersion 9之前: minSdkVersion 9
    • after: minSdkVersion 14之后: minSdkVersion 14

etc.等等。

I tried all the solution mentioned above我尝试了上面提到的所有解决方案

in Manifest.xml :Manifest.xml

  • add this code in top of your xml file within manifest tag:将此代码添加到清单标记内的 xml 文件顶部:

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

  • Then added :然后补充说:

    tools:replace="android:icon,android:theme,android:label,android:name" to the application tag tools:replace="android:icon,android:theme,android:label,android:name"到应用程序标签

but none of it worked.但没有一个奏效。 I needed to delete a xml file which was situated in我需要删除一个位于

mipmap-anydpi-v26/ic_launcher_round.xml mipmap-anydpi-v26/ic_launcher_round.xml

I was testing the application in我正在测试应用程序

Samsung Galaxy 8 with OS version 8.0.0操作系统版本为8.0.0 的三星 Galaxy 8

is it really a solution?它真的是一个解决方案吗?

在 AndroidManifest.xml 文件中,将以下内容添加到application节点:

tools:replace="android:appComponentFactory,android:icon,android:theme,android:label,android:name"

This issue occurs when you add a third-party library with @drawable/ic_launcher attribute thus android merger is unable to differentiate your app icon attribute and the library's attribute.当您添加具有 @drawable/ic_launcher 属性的第三方库时会出现此问题,因此 android 合并无法区分您的应用程序图标属性和库的属性。 To solve this add this line in your manifest file under the application tag要解决此问题,请在清单文件中的应用程序标记下添加此行

tools:replace="android:icon"

And update for Android Studio - Arctic Fox以及 Android Studio 的更新 - 北极狐

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    // DOCS: This is where we add the xmlns:tools reference
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app">
    // Permissions would go here
    // ...
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        ...
        tools:ignore="GoogleAppIndexingWarning"
        // DOCS: If you dont add this entry the xmlns:tools ref will not be found
        tools:replace="android:icon">
        <activity
            android:name=".MainActivity"
            android:exported="true" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM