Manifest Merger failed with multiple errors in Android Studio

Viewed 494267

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

43 Answers

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.

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

<application
        tools:node="replace">

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

android:exported="true/false"

I solved this with Refactor -> Migrate to AndroidX

GL

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.

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

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.

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.

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

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.

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> 

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

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.

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.

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

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

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

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

android:allowBackup="true"

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

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.

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"]
    }
}

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.

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>

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.

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".

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.

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.

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"/>

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.

I solved this by removing android:replace tag

Related