426

So, I am a beginner into Android and Java. I just began learning. While I was experimenting with Intent today, I incurred an error.

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

I found some solutions here and tried to implement them, but it did not work.

This is my build.gradle :

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.example.rohan.petadoptionthing"
    minSdkVersion 10
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}

This is my AndroidManifest :

<?xml version="1.0" encoding="utf-8"?>

package="com.example.rohan.petadoptionthing" >

<application

    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity android:name=".Second"
        />

    <activity android:name=".third"/>
    <activity android:name=".MainActivity"/>


</application>

This is my first week with coding, I am sorry if this is a really silly thing. I am really new to this and did not find any other place to ask. Sorry if I broke any rules

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Rohan
  • 4,456
  • 2
  • 11
  • 8

45 Answers45

1451

Open application manifest (AndroidManifest.xml) and click on Merged Manifest tab on bottom of your edit pane. Check the image below:

enter image description here

From image you can see Error in the right column, try to solve the error. It may help some one with the same problem. Read more here.

Also, once you found the error and if you get that error from external library that you are using, You have to let compiler to ignore the attribute from the external library. //add this attribute in application tag in the manifest

   tools:replace="android:allowBackup" 
                                                                                                                                          
   //Add this in the manifest tag at the top

   xmlns:tools="http://schemas.android.com/tools"
Yosidroid
  • 2,053
  • 16
  • 15
CLIFFORD P Y
  • 16,974
  • 6
  • 30
  • 45
125

Remove <activity android:name=".MainActivity"/> from your mainfest file. As you have already defined it as:

 <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

So, Manifest file showing ambiguity.

Android Geek
  • 8,956
  • 2
  • 21
  • 35
  • 50
    It's too bad that this is the accepted answer, when it only fixes Rowen's code but is entirely unhelpful for anyone else. The answer by CLIFFORD actually shows you how to "see logs" as the error message suggests. – Andrew Koster Jun 01 '19 at 21:22
  • It work very well only check and remove any duplicate entry in AndroidManifest.xml file. – vishwajit76 Sep 05 '19 at 07:27
70

For me THIS works -

Finding Merging Errors in AndroidManifest.xml

enter image description here

Click on Merged Manifest in AndroidManifest.xml

enter image description here

You can view manifest merging error in right column. It may help to solve this problem.

A J
  • 4,542
  • 5
  • 50
  • 80
  • 3
    This is a generic fix for this problem. This helps you find the real reason for any problem regarding this. – JoeGalind Aug 15 '18 at 14:44
66

I was also facing same issues, and after lot of research found the solution:

  1. 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.
  2. If build version of your app and modules not same. Again it should same ** In short, your app build.gradle file and manifest should have same configurations**
  3. There's no duplicacy like same permissions added in manifest file twice, same activity mention twice.
  4. If you have delete any activity from your project, delete it from your manifest file as well.
  5. Sometimes its because 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:

<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>
  1. If two dependencies are of not same version example: you are using dependency for appcompat v7:26.0.0 and for facebook com.facebook.android:facebook-android-sdk:[4,5) facebook uses cardview of version com.android.support:cardview-v7:25.3.1 and appcompat v7:26.0.0 uses cardview of version v7:26.0.0, So there is discripancy in two libraries and thus give error

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1) from [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 is also present at [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:41 to override.

So by using appcompat of version 25.3.1, We can avoid this error

By considering above points in mind, you will get rid of this irritating issue. You can check my blog too https://wordpress.com/post/dhingrakimmi.wordpress.com/23

Kimmi Dhingra
  • 2,249
  • 22
  • 21
19

Just add below code in your project Manifest application tag...

<application
        tools:node="replace">
sankalp
  • 617
  • 5
  • 14
18

If your project targeted Android 12 then Add this in all <activity> tags with <intent-filter>

android:exported="true/false"
Elias Fazel
  • 2,093
  • 16
  • 20
Aqif
  • 326
  • 3
  • 5
15

In addition to available solutions, please check this also.
If you have set android:allowBackup="false" in your AndroidManifest.xml then there may be a conflict for android:allowBackup="true" in other dependencies.

Solution
As suggested by @CLIFFORD P Y, switch to Merged Manifest in your AndroidManifest.xml. Android Studio will suggest to add tools:replace="android:allowBackup" in <application /> in your AndroidManifest.xml.

Chintan Shah
  • 1,744
  • 2
  • 26
  • 28
15

I was facing the same problem and I've just added one line in my manifest.xml and it worked for me.

tools:replace="android:allowBackup,icon,theme,label,name"> 

add this line under

<application
    android:name=".MyApplication"
    android:allowBackup="true"
    android:icon="@drawable/launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:screenOrientation="portrait"
    android:supportsRtl="true"
    android:theme="@style/AppThemecustom"
    tools:replace="android:allowBackup,icon,theme,label">

Hope it will help.

jeet.chanchawat
  • 5,842
  • 5
  • 38
  • 59
Pre_hacker
  • 1,352
  • 1
  • 17
  • 21
  • thank you so much! I was facing this issue in a very specific scenario caused by Zendesk support page, when clicking on "attach file". Tried so many answers from different questions and only your comment helped! – Natalie Apr 28 '19 at 14:53
  • @Natalie I'm glad it helped :) – Pre_hacker Jun 13 '19 at 06:51
11

I solved this with Refactor -> Migrate to AndroidX

GL

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62
10

solution for me was like this:

1- open manifest

2-On top right , check highlighted problems like below:

3-click on problems icon in red. this will open problems tab like below. problems tab

4- solve them one by one

8

In my case it was showing an error because there was a redundancy in <uses-permission> element. So, please check in your AndroidManifest.xml file for the same.

Android Studio version is 3.0.1

Operating System is Windows 7

Here is the screenshot for reference.

Screen-shot which shows redundancy in manifest file.

Parth Patel
  • 859
  • 2
  • 11
  • 28
  • While this was posted before @CLIFFORD-P-Y's answer, finding merging errors via the Merged Manifest view will catch this particular redundant error. – sonyisda1 Nov 26 '19 at 20:21
7

Usually occurs when you have errors in your manifest.Open AndroidManifest.xml .Click on the merged manifest tab.The errors can be seen there .Also include suggestions mentioned there.When I had a similar problem while importing com.google.android.gms.maps.model.LatLng ,it suggested me to include tools:overrideLibrary="com.google.android.gms.maps" in the application tag and the build was successful.

Archana Prabhu
  • 355
  • 4
  • 5
7

I was also facing this error. In the build log the last line was "Failed to compile values file".

So if you're facing the same issue, then just adding the following line in the gradle.properties file will most probably fix the issue.

android.enableJetifier=true

I mean it fixed Manifest Merger failed with multiple errors in Android Studio error for me.

Bucky
  • 1,116
  • 2
  • 18
  • 34
  • 1
    That did it for me. Thanks, Bucky! – FractalBob Apr 06 '22 at 16:43
  • In my case, gradle.properties had all lines repeated twice, that's why it was throwing this error. Actually, this happened during merging of two branches of my project, master has old codebase, and feature branch had new codebase. – Divya Gupta Nov 26 '22 at 10:39
3

My case i have fixed it by

build.gradle(Module:app)

defaultConfig {
----------
multiDexEnabled true
}
dependencies {
    ...........
    implementation 'com.google.android.gms:play-services-gcm:11.0.2'
    implementation 'com.onesignal:OneSignal:3.+@aar'
    }

This answer releted to OnSignal push notification

Md. Shofiulla
  • 2,135
  • 1
  • 13
  • 19
2
  1. In AndroidManifest.xml:

    • At application, add tools:replace="android:icon, android:theme and
    • At the Manifest root, add xmlns:tools="http://schemas.android.com/tools
  2. In build.gradle:

    • At root, add useOldManifestMerger true
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
ao wu
  • 21
  • 3
2

If after you add a Android Library Module and you get this error.
You can fix it by simple remove the android:label="@string/app_name" from the AndroidManifest.xml of your Android Library Module

Linh
  • 57,942
  • 23
  • 262
  • 279
2

The minium sdk version should be same as of the modules/lib you are using For example: Your module min sdk version is 26 and your app min sdk version is 21 It should be same.

Ejaz Ahmad
  • 614
  • 5
  • 12
2

I see the answers and they are complete and useful. Anyway, if you are completing the Jetpack Compose Testing codelab and you find this error in late 2021, the solution is not the accepted answer, you need to downgrade your target sdk version to 30.

In app/build.gradle, replace:

targetSdkVersion 31

with:

targetSdkVersion 30

And run the Android Tests again

voghDev
  • 5,641
  • 2
  • 37
  • 41
2

The simple way I did and it worked successfully is by adding android:exported="true" as follows,

<activity
        android:name=".MainActivity"
        ...
        android:exported="true">
IamADDICT
  • 49
  • 1
  • 5
1

for the past few days I was also going through the same issue. But after, a lot of research I finally found a solution for this.
In order to solve this issue, what you need to do is:
1. Check if your project's build.gradle file and the module's build.gradle file contain same versions of all dependencies.
2. Make sure, your project's compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersion matches the one in the modules or libraries that you have added into the project.

compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
    applicationId "com.example.appname"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 22
    versionName "2.0.3"

}

Hope, this helps.

1

I was using the FirebaseUI Library along with the Facebook SDK Library, which was causing me the issue.

implementation 'com.firebaseui:firebase-ui-database:0.4.4'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

And from [here][1], I got rid of this issue.

With the latest update of FirebaseUI library, previous version of Facebook SDK is also a part of it.

If you are using the both the libraries, please remove the Facebook SDK Library.

https://github.com/firebase/FirebaseUI-Android/issues/230

UPDATE

From the Android Studio 3.0 and the later versions, app.gradle file is required to use implementation or api instead of compile for adding the dependencies to the app.

Mohammedsalim Shivani
  • 1,793
  • 3
  • 19
  • 30
1

Open your gradle console, then you see gradle suggest you to add the particular line (Like: tools:replace="android:allowBackup" or tools:replace="android:label" etc). Add that line into your manifest file under tag and sync gradle, that's it.

Nazmus Saadat
  • 973
  • 9
  • 22
1

In my case it happened for leaving some empty intent-filter inside the Activity tag

    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

            <intent-filter>

            </intent-filter>

    </activity> 

So just removing them solved the problem.

    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
    </activity> 
Dr TJ
  • 3,241
  • 2
  • 35
  • 51
1

The following hack works:

  1. Add the xmlns:tools="http://schemas.android.com/tools" line in the manifest tag
  2. Add tools:replace="android:icon,android:theme,android:allowBackup,label,name" in the application tag
Shoaib Ahmed
  • 757
  • 7
  • 7
1

This error occurs because you don't have proper statements at the Manifest root such:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.test">

So you should remove additional texts in it.

Mohsen Hrt
  • 263
  • 2
  • 9
1

In my case, I solved it by updating the classpath in build.gradle (Project) file to the latest version.

It was like this:

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
}

After updating to the latest version:

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.4'
}

Everything worked fine! Hope this helps someone if all the above answers don't solve the issue.

1

in my case I was using multi models on firebase vision Dependencies in manifest file's meta-data tag, so I mixed them in one value parameter and it did solve my problem.here is how :

<meta-data
    android:name="com.google.mlkit.vision.DEPENDENCIES"
    android:value="ocr,langid"/>
0

As a newbie to Android Studio, in my case, I had moved an existing project from Eclipse to Android Studio and found that there was a duplicate definition of an activity within my Manifest.xml that hadn't been picked up by Eclipse was shown as a Gradle error.

I found this by going to the Gradle Console (bottom right of the screen).

JanB
  • 904
  • 9
  • 14
0

Happened with me twice when I refractor (Rename with SHIFT + F6) the name of a field in our files and it asks you to change it everywhere and we without paying attention change the name everywhere. For example, if you have a variable name "id" in your Java class and you rename it with SHIFT + F6. If you don't pay attention to the next dialog which will ask you wherever else it is going to change the id and you tick check all it will change all the id in your layout files from the new value.

Rakesh Yadav
  • 1,966
  • 2
  • 21
  • 35
0

this is very simple error only occur when you define any activity call two time in mainifest.xml file Example like

<activity android:name="com.futuretech.mpboardexam.Game" ></activity>

//and launcher also------like that



//solution:use only one 
legoscia
  • 39,593
  • 22
  • 116
  • 167
0

Put this at the end of your app module build.gradle:

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '25.3.0'
        }
    }
}}

from this

SHADOW NET
  • 69
  • 4
0

Supplement the answer Phan Van Linh. I deleted these lines:

  android:icon="@mipmap/ic_launcher"
  android:label="name"
Den
  • 170
  • 1
  • 8
0

i sloved this problem by removing below line from AndroidManifest.xml

android:allowBackup="true"
saigopi.me
  • 14,011
  • 2
  • 83
  • 54
0

Just migrate to Androidx as shown above and then set teh minimum sdk version to 26...with no doubts this works perfectly

0

In my case i was using some annotations from jetbrains library. I removed those annotations and dependencies and it worked fine.

So please check the libraries in android code and dependencies carefully.

Chaman Gurjar
  • 211
  • 3
  • 6
0

If you're using multiple manifestPlaceholder items in your build.gradle file, you must add them as array elements, instead of separate items.

For example, this will cause a build error or compile error: "java.lang.RuntimeException: Manifest merger failed with multiple errors":

android {
    ...
    defaultConfig {
        manifestPlaceholders = [myKey1: "myValue1"]
        manifestPlaceholders = [myKey2: "myValue2"] // Error!
    }
}

This will fix the error:

android {
    ...
    defaultConfig {
        manifestPlaceholders = [myKey1: "myValue1", myKey2: "myValue2"]
    }
}
Mr-IDE
  • 7,051
  • 1
  • 53
  • 59
0

This is because you are using the new Material library with the legacy Support Library.

You have to migrate android.support to androidx in order to use com.google.android.material.

If you are using android studio v 3.2 or above, simply

go to refactor ---> MIGRATE TO ANDROID X.

Do make a backup of your project.

Android
  • 1,420
  • 4
  • 13
  • 23
Fazal Jarral
  • 160
  • 1
  • 14
0

After seeing CLIFFORD's answer to see the error, what helped me to solve this issue was renaming 'android:namex' to 'android:name' in the intent-filter action tag. In case if the same solution helps someone else .

    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:namex="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Farhan
  • 61
  • 8
0

I had a weird encounter with this problem. when renaming variable name to user_name, I mistakenly rename all of the name to user_name for the project. So my xml tag <color name:""> became <color user_name:""> same goes for string, style, manifest too. But when I check merged manifest, it showed nothing, because I had only one manifest, nothing to find.

So, check if you have any malformed xml file or not.

touhid udoy
  • 4,005
  • 2
  • 18
  • 31
0

In my case my application tag includes:

 <application
    android:name=".common.MyApplication"
    android:allowBackup="false"
    android:extractNativeLibs="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:ignore="GoogleAppIndexingWarning"
    tools:replace="android:appComponentFactory">

I resolved this issue my adding new param as android:appComponentFactory=""

So my final application tag becomes:

<application
    android:name=".common.MyApplication"
    android:allowBackup="false"
    android:extractNativeLibs="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:ignore="GoogleAppIndexingWarning"
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="">

I encountered above issue when I tired using firebase-auth latest version as "19.3.1". Whereas in my project I was already using firebase but version was "16.0.6".

Nikhil Lotke
  • 605
  • 7
  • 15
0

check if you've any duplicate activity declared in the manifest. That was my mistake for this error and problem solved, after deleting the duplicate.

Kwesi Welbred
  • 69
  • 1
  • 5
0

For all of you that have the same problem but when you merge the manifest and there's no error at all this solution worked for me without edit your "Manifest" file and changed any configuration, delete this, delete that ect.

  1. Open your "settings.gradle" file.
  2. Add this code "gradlePluginPortal()".
  • If your start a new project the code automatically might be there if you are using the updated Android Studio but you need to add once more, like code below:

      pluginManagement {
      repositories {
          gradlePluginPortal()
          google()
          mavenCentral()
          jcenter()
          maven {url 'https://jitpack.io'}
      }
    

and put the code "gridlePluginCentral()" once more.

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven {url 'https://jitpack.io'}
        gradlePluginPortal()
    }
}

In my case problems like this happened usually when we use the github user libraries and used it for layout files or as "imports" in java files. It's always a good idea to keep your Android Studio up-to-date and leave the old version as there are usually changes to configuration, libraries and other supporting files. And it's best to avoid using libraries from github users, preferably using libraries from Google.

Jimi
  • 25
  • 4
0

In my case it was the Thumbs.db file that was causing the Manifest merge error, I just had to delete that file and it worked.

if you hit this button on android studio :

Expand all folders

Under mipmap you will see a file called Thumbs.db, remove that rebuild APK enter image description here

-1

Simple Answer Cross Check :

You might be defined Same Activity multiple times in the manifest.xml file.

OR

Activity or service or receiver you have defined in the manifest.xml file which is not in your project structure.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Please do not use code blocks for non-code content. Your answer does not contain code so it should not be indented. – Dharman Aug 22 '19 at 09:48
-2

I solved this by removing android:replace tag

adiga
  • 34,372
  • 9
  • 61
  • 83
Gurjap singh
  • 853
  • 8
  • 8