Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

Android: Adding Firebase Messaging - Menifest merger failed

I added this to my project:

implementation 'com.google.firebase:firebase-messaging:19.0.0'

and result:

ERROR: 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 <application> element at AndroidManifest.xml:15:5-71:19 to override.

So I go went ahead and added that line to the manifest, and I get this:

 Manifest merger failed with multiple errors, see logs

I went to merging errors, and I see this now:

Error: tools:replace specified at line:15 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 14

Here are my current gradle dependencies:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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 project(path: ':bluefire-api-v25.5')
    implementation "com.jakewharton:butterknife:8.5.1"
    annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
    implementation 'com.myhexaville:smart-image-picker:1.0.4'
    implementation 'com.github.gcacace:signature-pad:1.2.1'

    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

    implementation 'com.android.support:recyclerview-v7:28.0.0'

    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:19.0.0'
}

I hit a dead-end. Thoughts?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To troubleshoot your problem, Follow below steps:

  • Open your AndroidManifest.xml
  • There is a tab on the bottom of the Ide named "Merged Manifest". Open it.
  • This will list out the Merged Manifest at the left and their sources at right.

  • As you are facing Manifest "merger failed" error, you will see Some Merging Errors.

  • This will tell you exactly which part is in conflict. Resolve that and you are done.

In your case, the error is because of the conflict between different support libraries. i.e. between androidx and older support lib. Migrate all your support library to AndroidX. The latest firebase library you are using is already migrated from the Android Support Libraries to the Jetpack (AndroidX) Libraries.

This post will help you to migrate to AndroidX : Migrating to AndroidX


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...