繁体   English   中英

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

[英]Android studio Gradle icon error, Manifest Merger

我一直看到这条消息,但不知道如何永久解决它。

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

即使使用我的图标,也尝试将android:replace="android:icon"到我的清单中。

我尝试从库中删除android:icon="@drawable/ic_launcher但它在我构建时不断返回,因为它是从 maven 导入的

有任何想法吗 ?

这似乎是 gradle 的主要合并工具的错。

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

通过添加到我的清单标签xmlns:tools="http://schemas.android.com/tools"解决了这个问题

然后将tools:replace="android:icon,android:theme"到应用程序标签

这告诉合并使用我的清单图标和主题,而不是其他库

希望有帮助谢谢

我有同样的问题,我通过将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>

我有同样的错误,只是这段代码解决了我的问题,我想与您分享:

Manifest.xml

  • 将此代码添加到您的 xml 文件顶部:

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

  • 然后补充说:

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

shimi_tap 的回答就够了。 需要记住的是,只选择你需要的。 从{图标、名称、主题、标签}中选择。 我添加了tools:replace="android:icon,android:theme" ,它不起作用。 我添加了tools:replace="android:icon,android:theme,android:label,android:name" ,它不起作用。 当我添加tools:replace="android:icon,android:theme,android:label"时它起作用了。 因此,找出清单文件中的冲突到底是什么。

只需将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

经过长时间的谷歌搜索后得到了解决方案

只需获取您的ic_launcher并将其粘贴到您的 drawables 文件夹中,

转到您的清单并更改 android:icon="@drawable/ic_launcher"

清理你的项目并重建

希望对你有帮助

我在将图标从 drawable 更改为 mipmap 时遇到了这个问题。

我只是错过了线路

tools:replace="android:icon"

在清单中。

出于某种原因,android studio 不喜欢从可绘制文件夹中调用应用程序图标。 所以在这种情况下,我在 res 文件夹下创建了 mipmap 资源目录。

右键单击 res 文件夹 > 新建 > android 资源目录 > 资源类型:mipmap ,现在将任何图标放入其中,然后将其引用到清单文件中。 分享这个,因为这种方法对我有用。

android:icon:@drawable/ic_launcher"

android:icon="@mipmap/ic_launcher"

如果这些都不起作用,请关闭 Android Studio。 转到 app/src/main,在文本编辑器(如 sublime)中打开文件 AndroidManifest.xml,删除/替换错误行,保存并重新打开 android studio。

当一个属性值包含一个占位符(见下面的格式)时,清单合并会用一个注入的值交换这个占位符值。 注入值在 build.gradle 中指定。 占位符值的语法是 ${name},因为 @ 是为链接保留的。 在最后一次文件合并发生之后,在写出合并后的 android 清单文件之前,所有带有占位符的值都将与注入的值交换。 如果变量名称未知,将生成构建损坏。

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

Shimi_tap 的答案是解决问题的正确方法。 如果你想使用旧的合并工具,你可以将它添加到 build.gradle 文件中

android { useOldManifestMerger true }

对我来说,这个问题是在更新 Google Play 服务后发生的。 我使用的库之一在它的 Gradel 参考中使用“+”合并了这个库,比如

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

这产生了一个问题,因为该库所针对的最小版本小于当前版本的 Google Play 服务所针对的版本。 我通过简单地查看日志发现了这一点。

在您的.gradle更改 MinSDK,例如:

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

等等。

我尝试了上面提到的所有解决方案

Manifest.xml

  • 将此代码添加到清单标记内的 xml 文件顶部:

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

  • 然后补充说:

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

但没有一个奏效。 我需要删除一个位于

mipmap-anydpi-v26/ic_launcher_round.xml

我正在测试应用程序

操作系统版本为8.0.0 的三星 Galaxy 8

它真的是一个解决方案吗?

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

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

当您添加具有 @drawable/ic_launcher 属性的第三方库时会出现此问题,因此 android 合并无法区分您的应用程序图标属性和库的属性。 要解决此问题,请在清单文件中的应用程序标记下添加此行

tools:replace="android:icon"

以及 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