How can i remove manifest merge errors

manifest merger failed
android manifest merge
tools:replace="android:appcomponentfactory"
manifest merger failed with multiple errors, see logs
android multiple manifest files
how to fix manifest merger failed
suggestion: add 'tools:replace="android:value"'
manifest merger failed : attribute application@appcomponentfactory react native

I added MaterialAlertDialog to my project which was not using androidx. This caused errors during the next build. So i removed the 'implementation' statement from app level build gradle. But still i am having manifest merge error when i try to build my project.

This is the error i get during build time

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

So far i have tried the following solutions,Close and reload my project. Do a clean and rebuild .delete the .gradle and .idea folders in my project and build it again

These are the dependencies in my project

    dependencies 
    {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
            })
        implementation "com.android.support:appcompat-v7:${android_support_version}"
        implementation "com.android.support:design:${android_support_version}"
        implementation 'com.github.lzyzsd:circleprogress:1.1.0@aar'
        implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
        implementation 'commons-net:commons-net:3.3'
        implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
            transitive = true
        }

        implementation "de.hdodenhof:circleimageview:${circle_imageview}"
        implementation "com.github.bumptech.glide:glide:${glide_version}"
        implementation "com.android.support:recyclerview-v7:${android_support_version}"
        implementation "com.android.support:cardview-v7:${android_support_version}"
        implementation "com.squareup.retrofit2:retrofit:${retrofit_service_version}"
        implementation "com.squareup.retrofit2:converter-gson:${retrofit_gson_convertor}"
        implementation "com.clough.android.androiddbviewer:androiddbviewer:${dbviewer_version}"
        implementation "com.android.support:multidex:${multidex_version}"
        implementation "com.github.crosswall:Android-Coverflow:${viewPager_version}"
        implementation "com.squareup.okhttp3:logging-interceptor:3.4.0"
        implementation project(':sdkui')
        implementation 'com.github.ronaldsmartin:Material-ViewPagerIndicator:1.0.4'
        implementation 'com.google.android.gms:play-services-base:16.0.1'
        implementation 'com.google.android.gms:play-services-identity:16.0.0'
        implementation 'com.google.android.gms:play-services-auth:16.0.1'
        implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
        implementation 'com.google.firebase:firebase-config:16.1.0'
        implementation 'com.google.firebase:firebase-core:16.0.4'
        implementation 'com.google.firebase:firebase-messaging:20.0.0'
    }
    apply plugin: 'com.google.gms.google-services'

I am answering this just to specify the step it took to clear my issue.

  1. I removed the gradle dependency for the MaterialDesign.
  2. The cashe issue was solved by doing File-> Invalidate Cache & restart

Since Firebase was changed to ver 20 before restart the issue persisted.

Reduced Firebase version to 17.3.4 this fixed everything.

How can i remove manifest merge errors, I am answering this just to specify the step it took to clear my issue. I removed the gradle dependency for the MaterialDesign. The cashe issue  Manifest merger failed with multiple errors is a common problem in android development. In this post, I will tell you what is the reason behind that, What

Add these lines in your Manifest file.

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

Manifest File

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

Manifest merger failed error, Remove the conflicting attribute from the library (or lower-level) manifest file. In this case, the ANDROID_APPLICATION:Library:unspecified:9:18  This page describes how manifest merging works and how you can apply merge preferences to resolve merge conflicts. Tip: Use the Merged Manifest view to preview the results of your merged manifest and find conflict errors.

Try this

With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

If you have any Maven dependencies that have not been migrated to the AndroidX namespace, the Android Studio build system also migrates those dependencies for you when you set the following two flags to true in your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

Add these lines in your Manifest file in Application TAG.

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

Manifest Merging, Manifest merge conflicts are resolved at the XML node and attribute levels based from the merged manifest. remove-All: Removes all lower priority elements of  Try this. With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.. If you have any Maven dependencies that have not been migrated to the AndroidX namespace, the Android Studio build system also migrates those dependencies for you when you set the following two flags to true in your gradle

Manifest merger failed : Attribute application , RuntimeException: Manifest merger failed with multiple errors, see logs so remove com.android.support dependecies and move them to use  Handling Manifest Merge Build Errors. During the build process, the manifest merge process stores a record of each merge transaction in the manifest-merger-<productFlavor>-report.txt file in the module build/outputs/logs folder. A different log file is generated for each of the module's build variants.

Manifest merger failed error in an android studio, Manifest merger failed with multiple errors is a common problem in Let's see your project, If you are using androidx, than remove support and  Ah, yes, of course, it makes sense that you'd still need the replace attributes! Good catch. Ok, as a next step, let's look at the merged manifest directly, and make sure all those nodes are being replaced correctly.

Manifest merger failed with multiple errors, unity package or installing via the unity package manager) I get a manifest merger failed error. Remove the line from the AndroidManifest.xml ( <uses-sdk​  Then, manifest files of types (3) are usually merged into the resulting main manifest from previous step. The rules for merging depend on each node type and can be altered using “tools:” namespace attributes. Because of multiple product flavors and build types there can be a matrix of possible manifest files to merge.

Comments
  • You are using firebase libraries which require androidx migration.
  • Did you try: Clean and Rebuild on Android Studio?
  • @Gabriele Mariotti My project was working fine until i tried adding the Dependency for MaterialAlertDialog. So i am not sure if firebase is cauing this issue.
  • @DeepakJanardhanan Also the Material Components Library requires androidx libraries.
  • @GabrieleMariotti what you said was correct. It was the Firebase that caused the issue. I reduced it to 17.3.4 and the build was successful.
  • My thanks to Gabriele Mariotti whose comment under my question allowed me to solve the issue.
  • this did not work. It simply caused additional errors to occur. I would like to mention that i am not trying to convert to androidx but simply removing the single gradle entry that used androidx.
  • This is a hack and doesn't solve the core issue. Instead, make sure you update all libraries. I looked at the build.gradle and in 0.5 seconds I found com.android.support:appcompat-v7 which isn't allowed in AndroidX. This and other outdated libraries should be removed or replaced.
  • Updating code with the latest version is always better way
  • Surpressing an error message using tools:replace combined with android:appComponentFactory is a hack. You aren't solving the core issue, you are only applying a temporary band aid to a large gaping wound. I found a nice definition here: softwareengineering.stackexchange.com/questions/73334/… .