[android] 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.

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

Any ideas ?

This question is related to android gradle android-studio

The answer is


For some reason android studio doesn't like calling app icon from drawable folder. So in that case I created mipmap resource directory under res folder.

Right click res folder > new > android resource directory > resource type: mipmap and now drop any icon in there then reference that into manifest file. Sharing this since this method worked for me.

android:icon:@drawable/ic_launcher"

to

android:icon="@mipmap/ic_launcher"


I tried all the solution mentioned above

in Manifest.xml :

  • add this code in top of your xml file within manifest tag:

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

  • Then added :

    tools:replace="android:icon,android:theme,android:label,android:name" to the application tag

but none of it worked. I needed to delete a xml file which was situated in

mipmap-anydpi-v26/ic_launcher_round.xml

I was testing the application in

Samsung Galaxy 8 with OS version 8.0.0

is it really a solution?


For me, this issue occurred after updating Google Play Services. One of the libraries I was using incorporated this library using the "+" in its gradel reference, like

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. I found this by simply looking in the logs.


Shimi_tap's answer is the right way to fix the problem. If you want to use old merger tool you can add this to build.gradle file

android { useOldManifestMerger true }


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

<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 :

  • add this code in top of your xml file :

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

  • Then added :

    tools:replace="android:icon,android:theme,android:label,android:name" to the application tag


Just add xmlns:tools="http://schemas.android.com/tools" to your manifest tag, and then you need to add tools:replace="android:icon" before android:icon="@mipmap/ic_launcher".


This error also occurs when your app's minSdk is higher than any library's minSdk.

app's minSdk >= libraries minSdk

The answer of shimi_tap is enough. 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. I added tools:replace="android:icon,android:theme,android:label,android:name", it does not work. It works when I added tools:replace="android:icon,android:theme,android:label". So find out what the conflict exactly is in your manifest files.


In your .gradle change MinSDK, for example:

  • build.gradle (Module: app)
    • before: minSdkVersion 9
    • after: minSdkVersion 14

etc.


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. The syntax for placeholder values is ${name} since @ is reserved for links. 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. 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


I had this problem changing the icon from drawable to mipmap.

I only missed the line

tools:replace="android:icon"

in the manifest.


Within the AndroidManifest.xml file, add the following to the application node:

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

If nothing of that work, close 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.


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. To solve this add this line in your manifest file under the application tag

tools:replace="android:icon"

GOT THE SOLUTION AFTER ALOT OF TIME GOOGLING

just get your ic_launcher and paste it in your drawables folder,

Go to your manifest and change android:icon="@drawable/ic_launcher"

Clean your project and rebuild

Hope it helps you


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK