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

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.

查看更多
戒情不戒烟
3楼-- · 2020-01-22 13:35

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.

查看更多
Evening l夕情丶
4楼-- · 2020-01-22 13:35

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')

查看更多
走好不送
5楼-- · 2020-01-22 13:36

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

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2020-01-22 13:36

Follow these steps:

  • Goto Refactor and Click Migrate to AndroidX
  • Click Do Refactor
查看更多
\"骚年 ilove
7楼-- · 2020-01-22 13:38

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

查看更多
登录 后发表回答