Rohan
Rohan

Reputation: 4666

Manifest Merger failed with multiple errors in Android Studio

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

Upvotes: 447

Views: 640012

Answers (30)

Sriraksha
Sriraksha

Reputation: 559

Make sure you have selected the right build variant.

Upvotes: 0

Tobia
Tobia

Reputation: 9506

I had to update this dependecy from build.gradle:

androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

to

androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

Upvotes: 1

IamADDICT
IamADDICT

Reputation: 59

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

<activity
        android:name=".MainActivity"
        ...
        android:exported="true">

Upvotes: 3

talent makhanya
talent makhanya

Reputation: 29

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

Upvotes: 0

Payam Karamvandi
Payam Karamvandi

Reputation: 51

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

Upvotes: 2

Jimi
Jimi

Reputation: 25

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.

Upvotes: 0

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

Upvotes: 11

Peacemaker Otoo
Peacemaker Otoo

Reputation: 129

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.

Upvotes: 0

Bucky
Bucky

Reputation: 1206

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.

Upvotes: 9

voghDev
voghDev

Reputation: 5791

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

Upvotes: 2

Royce Thomas
Royce Thomas

Reputation: 21

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.

Upvotes: 1

Aqif
Aqif

Reputation: 326

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

android:exported="true/false"

Upvotes: 18

Mohsen Hrt
Mohsen Hrt

Reputation: 303

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.

Upvotes: 1

CLIFFORD P Y
CLIFFORD P Y

Reputation: 17404

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"

Upvotes: 1482

Nikhil Lotke
Nikhil Lotke

Reputation: 665

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

Upvotes: 0

touhid udoy
touhid udoy

Reputation: 4444

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.

Upvotes: 0

Farhan
Farhan

Reputation: 81

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>

Upvotes: 0

Ambilpura Sunil Kumar
Ambilpura Sunil Kumar

Reputation: 1463

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.

Upvotes: -1

Mohammedsalim Shivani
Mohammedsalim Shivani

Reputation: 1833

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.

Upvotes: 1

Fazal Jarral
Fazal Jarral

Reputation: 170

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.

Upvotes: 0

Mr-IDE
Mr-IDE

Reputation: 7641

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

Upvotes: 0

Chaman Gurjar
Chaman Gurjar

Reputation: 221

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.

Upvotes: 0

Braian Coronel
Braian Coronel

Reputation: 22867

I solved this with Refactor -> Migrate to AndroidX

GL

Upvotes: 11

Gurjap singh
Gurjap singh

Reputation: 1033

I solved this by removing android:replace tag

Upvotes: -2

Shoaib Ahmed
Shoaib Ahmed

Reputation: 765

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

Upvotes: 1

sammy mutahi
sammy mutahi

Reputation: 17

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

Upvotes: 0

saigopi.me
saigopi.me

Reputation: 14908

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

android:allowBackup="true"

Upvotes: 0

Dr TJ
Dr TJ

Reputation: 3356

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> 

Upvotes: 1

sankalp
sankalp

Reputation: 757

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

<application
        tools:node="replace">

Upvotes: 22

Ejaz Ahmad
Ejaz Ahmad

Reputation: 644

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.

Upvotes: 2

Related Questions