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:49

Just change "rc01" in first and last line inside dependencies to "alpha1" This is working for me

查看更多
仙女界的扛把子
3楼-- · 2020-01-22 13:50

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.

查看更多
你好瞎i
4楼-- · 2020-01-22 13:51

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'
查看更多
【Aperson】
5楼-- · 2020-01-22 13:51

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

查看更多
爷、活的狠高调
6楼-- · 2020-01-22 13:52

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

查看更多
你好瞎i
7楼-- · 2020-01-22 13:53

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

查看更多
登录 后发表回答