Android Material and appcompat Manifest merger fai

2020-01-22 13:04发布

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

30条回答
叼着烟拽天下
2楼-- · 2020-01-22 13:45

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.

查看更多
三岁会撩人
3楼-- · 2020-01-22 13:46

Add these lines inside in AndroidManifest.xml file.

tools:replace="android:appComponentFactory"

android:appComponentFactory="whateverString"
查看更多
不美不萌又怎样
4楼-- · 2020-01-22 13:47

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'

I hope that this may help someone.

查看更多
太酷不给撩
5楼-- · 2020-01-22 13:48

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

查看更多
疯言疯语
6楼-- · 2020-01-22 13:48

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

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

enter image description here

查看更多
别忘想泡老子
7楼-- · 2020-01-22 13:48

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.
查看更多
登录 后发表回答