[android] Android Material and appcompat Manifest merger failed

I have next grade

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.material:material:1.0.0-rc01'
}

But when I want to build app I get next log:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.

Okey! Go to manifest and do it:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ru.chopcode.myapplication">

    <application
        tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>

</manifest>

Then I get this error in my Logcat:

Manifest merger failed with multiple errors, see logs that I have Linked with it

The answer is


I had similar problem. Added two lines in gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

These two lines automatically resolved my dependency conflicts between google's files and third party dependencies. Here's the link to follow: https://developer.android.com/topic/libraries/support-library/androidx-overview#new-project


I faced same error when i try to add Kotlin-KTX library to my project.

I try to AndroidX migration, and problem fixed!

Refactor/Migrate to AndroidX


Reason of Fail

You are using material library which is part of AndroidX. If you are not aware of AndroidX, please go through this answer.

One app should use either AndroidX or old Android Support libraries. That's why you faced this issue.

For example -

In your gradle, you are using

  • com.android.support:appcompat-v7 (Part of old --Android Support Library--)
  • com.google.android.material:material (Part of AndroidX) (AndroidX build artifact of com.android.support:design)

Solution

So the solution is to use either AndroidX or old Support Library. I recommend to use AndroidX, because Android will not update support libraries after version 28.0.0. See release notes of Support Library.

Just migrate to AndroidX.Here is my detailed answer to migrate to AndroidX. I am putting here the needful steps from that answer.

Before you migrate, it is strongly recommended to backup your project.

Existing project

  • Android Studio > Refactor Menu > Migrate to AndroidX...
  • It will analysis and will open Refractor window in bottom. Accept changes to be done.

image

New project

Put these flags in your gradle.properties

android.enableJetifier=true
android.useAndroidX=true

Check @Library mappings for equal AndroidX package.

Check @Official page of Migrate to AndroidX

What is Jetifier?


In my case, this is working perfectly.. I have added below two line codes inside manifest file

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

Credit goes to this answer.

Manifest file Example


Simple Solutions - migrate into AndroidX

in the gradle.properties, just add below two scripts

android.useAndroidX=true
android.enableJetifier=true

What was the reason ?

All packages in AndroidX live in a consistent namespace starting with the string androidx. The Support Library packages have been mapped into the corresponding androidx.* packages. For a full mapping of all the old classes and build artifacts to the new ones, see the Package Refactoring page.

Please see the Package Refactoring page


Just remove the android.support dependancy

    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

Quoting From Material Guidelines

If you don’t want to switch over to the new androidx and com.google.android.material packages yet, you can use Material Components via the com.android.support:design:28.0.0-alpha3 dependency.

Note: You should not use the com.android.support and com.google.android.dependencies in your app at the same time.

Just removing this dependency works fine

    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

Here is complete dependencies example

    dependencies {
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       implementation 'com.google.android.material:material:1.0.0-beta01'
       implementation 'com.android.support.constraint:constraint-layout:1.1.2'
       testImplementation 'junit:junit:4.12'
       androidTestImplementation 'com.android.support.test:runner:1.0.2'
       androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
   }

As of Android P, the support libraries have been moved to AndroidX

Please do a refactor for your libs from this page.

https://developer.android.com/topic/libraries/support-library/refactor


See This Image and Add This line in your android AndroidManifest.xml

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

enter image description here


Add these lines inside in AndroidManifest.xml file.

tools:replace="android:appComponentFactory"

android:appComponentFactory="whateverString"

  1. Please go to Refactor->Migrate->Migrate to Android X.

  2. Please add this to your gradle.properties file:

    android.enableJetifier=true
    android.useAndroidX=true
    

And perform Sync.


just add these two lines of code to your Manifest file

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

Migrate to androidX if it an existing project. If it is new project add these two flags to Gradle.propeties

android.enableJetifier=true  
android.useAndroidX=true

for more detail steps https://developer.android.com/jetpack/androidx or check this What is AndroidX?


Follow these steps:

  • Goto Refactor and Click Migrate to AndroidX
  • Click Do Refactor

Its all about the library versions compatibility

I was facing this strange bug couple of 2 hours. I resolved this error by doing these steps

hange your build.gradle dependencies into

  implementation 'com.google.android.gms:play-services-maps:17.0.0'

to

  implementation 'com.google.android.gms:play-services-maps:15.0.0'

Only If you don't want to use androidx

So in my case, I am using a library that was using androidx but I am not using androidx so when I downgraded that library version the problem was resolved.

In my Case:

implementation 'com.github.turing-tech:MaterialScrollBar:13.+'

the above-mentioned library makes problem 13.+ will automatically get a new version of the library which using androidx. So I downgraded library version to:

implementation 'com.github.turing-tech:MaterialScrollBar:13.2.5'

And the problem was resolved.


Finally found a quick and easy solution by adding two lines in the android/build.gradle file.

googlePlayServicesVersion = "16.+"

firebaseVersion = "17.6.0"

Please follow this 100% correct.


This issue mainly happened for old dependencies.

There have 2 solution:

First one:

Update all old dependencies and ClassPaths from Project level gradle files.

classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'

Second one:

Your project Migrate to AndroidX

From Android Studio Menu -> Refanctor -> Migrate to AndroidX

Thanks, let me know if anyone help from this answer.


Create new project and compare your build.gradle files and replaced all

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'

and other dependencies with the same as were in a new project someting like that

implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'

implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'

androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'

implementation 'androidx.core:core-ktx:1.0.0-alpha3'

And then fixed imports to use androidx in kotlin files.


1.Added these codes to at the end of your app/build.gradle:

configurations.all {
   resolutionStrategy.force 'com.android.support:support-v4:28.0.0' 
   // the above lib may be old dependencies version       
    }

2.Modified sdk and tools version to 28:

compileSdkVersion 28
buildToolsVersion '28.0.3'
targetSdkVersion  28

3.In your AndroidManifest.xml file, you should add two line:

<application
    android:name=".YourApplication"
    android:appComponentFactory="AnyStrings"
    tools:replace="android:appComponentFactory"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">

Or Simply

  • Go to Refactor (Studio -> Menu -> Refactor)
  • Click the Migrate to AndroidX. it's working
  • it's working.

If you do not intend to migrate to AndroidX follow the below steps

  1. In terminal type gradlew app:dependencies
  2. After dependencies are shown in the window press Ctrl+f and type androidX
  3. You will find all the dependencies which are using androidx lib internally you may have to downgrade that or use alternative for that to ensure it is no longer using androidX libs internally.

All I did was go to the "Refactor" option on the top menu.

Then select "Migrate to AndroidX"

Accept to save the project as a zip file.

Please update Android Studio as well as Gradle to ensure no problems are encountered.


First of all be sure to add this line in manifest tag

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

Then add tools replace your suggested one in Android studio


  • Go to Refactor (Image )
  • Click the Migrate to AndroidX. it's working
  • it's working.

I don't know this is the proper answer or not but it worked for me

Increase Gridle Wrapper Property

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

and Build Gridle to

    classpath 'com.android.tools.build:gradle:3.4.2'

its showing error because of the version.


I had this same problem for three days.

It is like android wants us to either use Kotlin Or AndroidX, they are doing away with Android.

But this is how I solved it.

  • I migrated my project to AndroidX. This does not bring in any errors related to this issue in question, It updates files respectively. No method, class or variable name needs to be changed in your application.

NB: You must be using the latest Libraries (build.grudle file) in the latest stable version of android studio 3.4.1


For solving this issue i would recommend to define explicitly the version for the ext variables at the android/build.gradle at your root project

ext {
    googlePlayServicesVersion = "16.1.0" // default: "+"
    firebaseVersion = "15.0.2" // default: "+"

    // Other settings
    compileSdkVersion = <Your compile SDK version> // default: 23
    buildToolsVersion = "<Your build tools version>" // default: "23.0.1"
    targetSdkVersion = <Your target SDK version> // default: 23
    supportLibVersion = "<Your support lib version>" // default: 23.1.1
}

reference https://github.com/zo0r/react-native-push-notification/issues/1109#issuecomment-506414941


In may case I didn't want to pass to androidX. And I have to check my last changes. I figure out that the new component was --> lottie 2.8.0

So I downgrade it to: implementation 'com.airbnb.android:lottie:2.7.0'


in my case i am add in manifest file `

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

application tag of course, It will work


Change proguardFile in build.gradle (Module: app) to the following

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

instead of

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

This worked for me


Try this

tools:replace="android:appComponentFactory"
android:appComponentFactory="android.support.v4.app.CoreComponentFactory"

Rebuild your project.


I had the same error when working with Groupie. implementation 'com.xwray:groupie:2.3.0'

I solved it by changing version to implementation 'com.xwray:groupie:2.1.0'


if you are using capacitor, upgrade to capacitor/core 2.0.1 or up in your package.json


I'm also facing the same issue, for your android studio, you just change the android Gradle plugin version 3.3.2 and Gradle version is 5.1.1


change your build.gradle dependencies into

 implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'

or

 implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

Questions with android tag:

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 Why am I seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors after upgrading to Cordova Android 8? "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 No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator WebView showing ERR_CLEARTEXT_NOT_PERMITTED although site is HTTPS WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' GoogleMaps API KEY for testing Can I use library that used android support with Androidx projects. How to allow all Network connection types HTTP and HTTPS in Android (9) Pie? Android Material and appcompat Manifest merger failed Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 How to format DateTime in Flutter , How to get current time in flutter? How to change package name in flutter? Failed to resolve: com.android.support:appcompat-v7:28.0 What is AndroidX? Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve FirebaseInstanceIdService is deprecated installation app blocked by play protect Handling back button in Android Navigation Component Android design support library for API 28 (P) not working 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 Install Android App Bundle on device Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. How to develop Android app completely using python? Invoke-customs are only supported starting with android 0 --min-api 26 Flutter.io Android License Status Unknown How to open Android Device Monitor in latest Android Studio 3.1 Default interface methods are only supported starting with Android N How can I change the app display name build with Flutter? Error:(9, 5) error: resource android:attr/dialogCornerRadius not found error: resource android:attr/fontVariationSettings not found Flutter does not find android sdk Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0) Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior flutter run: No connected devices Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation' PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT (in windows 10)

Questions with android-gradle-plugin tag:

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve 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 Invoke-customs are only supported starting with android 0 --min-api 26 error: resource android:attr/fontVariationSettings not found Exception : AAPT2 error: check logs for details Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error) "The specified Android SDK Build Tools version (26.0.0) is ignored..." Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0 Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Android studio 3.0: Unable to resolve dependency for :app@dexOptions/compileClasspath': Could not resolve project :animators Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0] Failed to resolve: com.android.support:appcompat-v7:26.0.0 No resource found that matches the given name: attr 'android:keyboardNavigationCluster'. when updating to Support Library 26.0.0 Failed to resolve: com.android.support:cardview-v7:26.0.0 android Android dependency has different version for the compile and runtime ionic 2 - Error Could not find an installed version of Gradle either in Android Studio Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2 Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7 Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK - Android Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored' error: package com.android.annotations does not exist Automatically accept all SDK licences Class file for com.google.android.gms.internal.zzaja not found Error:Conflict with dependency 'com.google.code.findbugs:jsr305' Could not find method android() for arguments Android Studio - Failed to apply plugin [id 'com.android.application'] The number of method references in a .dex file cannot exceed 64k API 17 Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease' Error: No toolchains found in the NDK toolchains folder for ABI with prefix: llvm configuring project ':app' failed to find Build Tools revision "Gradle Version 2.10 is required." Error Gradle version 2.2 is required. Current version is 2.10 Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it" Error:Execution failed for task ':app:transformClassesWithDexForDebug' Error:Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ Error: Execution failed for task ':app:clean'. Unable to delete file HttpClient won't import in Android Studio Android Gradle Apache HttpClient does not exist? Error running android: Gradle project sync failed. Please fix your project and try again Could not find or load main class org.gradle.wrapper.GradleWrapperMain Execution failed for task ':app:compileDebugAidl': aidl is missing finished with non zero exit value Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to Error:Execution failed for task ':ProjectName:mergeDebugResources'. > Crunching Cruncher *some file* failed, see logs

Questions with build.gradle tag:

Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Android dependency has different version for the compile and runtime Setting up Gradle for api 26 (Android) What's the difference between implementation and compile in Gradle? More than one file was found with OS independent path 'META-INF/LICENSE' Android Studio - Failed to notify project evaluation listener error Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2 All com.android.support libraries must use the exact same version specification DELETE_FAILED_INTERNAL_ERROR Error while Installing APK Error:Conflict with dependency 'com.google.code.findbugs:jsr305' Could not find method android() for arguments How to set an environment variable from a Gradle build? Execution failed for task ':app:processDebugResources' even with latest build tools configuring project ':app' failed to find Build Tools revision Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package android : Error converting byte to dex Error:Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle Gradle Error:Execution failed for task ':app:processDebugGoogleServices' Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M? Execution failed for task ':app:compileDebugAidl': aidl is missing Java finished with non-zero exit value 2 - Android Gradle Android Studio gradle takes too long to build Error:Execution failed for task ':ProjectName:mergeDebugResources'. > Crunching Cruncher *some file* failed, see logs Install / upgrade gradle on Mac OS X Getting Gradle dependencies in IntelliJ IDEA using Gradle build Android Studio update -Error:Could not run build action using Gradle distribution Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip' How/when to generate Gradle wrapper files? Gradle - Could not find or load main class Add resources, config files to your jar using gradle Adding local .aar files to Gradle build using "flatDirs" is not working Autoincrement VersionCode with gradle extra properties android studio 0.4.2: Gradle project sync failed error How to run JUnit tests with Gradle? How to add local .jar file dependency to build.gradle file? How do I tell Gradle to use specific JDK version? Copy existing project with a new name in Android Studio Android Studio: Plugin with id 'android-library' not found Gradle Build Android Project "Could not resolve all dependencies" error Gradle: Execution failed for task ':processDebugManifest' Building and running app via Gradle and Android Studio is slower than via Eclipse How to manually include external aar package using new Gradle Android Build System Can the Android layout folder contain subfolders? How can I use external JARs in an Android project?

Questions with gradle-plugin tag:

Android Material and appcompat Manifest merger failed What's the difference between implementation and compile in Gradle? Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)