Android:添加Firebase消息传递-合并合并失败

svg*_*in3 5 android

我将此添加到我的项目中:

implementation 'com.google.firebase:firebase-messaging:19.0.0'
Run Code Online (Sandbox Code Playgroud)

结果:

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.
Run Code Online (Sandbox Code Playgroud)

所以我继续将那行添加到清单中,我得到了:

 Manifest merger failed with multiple errors, see logs
Run Code Online (Sandbox Code Playgroud)

我去合并错误,现在我看到了:

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

这是我当前的gradle依赖项:

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'
}
Run Code Online (Sandbox Code Playgroud)

我死定了。有什么想法吗?

Deˣ*_*Deˣ 5

要解决您的问题,请执行以下步骤:

  • 打开你的 AndroidManifest.xml
  • 在Ide的底部有一个选项卡,名为“ Merged Manifest ”。打开它。
  • 这将在左侧列出合并清单,在右侧列出其来源。

  • 当您遇到清单“ 合并失败 ”错误时,您会看到某些合并错误

  • 这将准确告诉您哪个部分存在冲突。解决该问题,您就完成了。

对于您而言,该错误是由于不同支持库之间的冲突引起的。即在androidx和较早的支持库之间。将您所有的支持库迁移到AndroidX。您正在使用的最新Firebase库已从Android支持库迁移到Jetpack(AndroidX)库

这篇文章将帮助您迁移到AndroidX:迁移到AndroidX


Abh*_*iya 4

此问题是由于 supportandoidx库同时存在而发生的。

检查Firebase 发行说明

此版本是主要版本更新,包含重大更改。在此版本中,库已从 Android 支持库迁移到 Jetpack (AndroidX) 库。除非您在应用程序中进行以下更改,否则更新的库将不起作用: 将 com.android.tools.build:gradle 升级到 v3.2.1 或更高版本。将compileSdkVersion升级到28或更高版本。更新您的应用程序以使用 Jetpack (AndroidX);请按照迁移到 AndroidX 中的说明进行操作。

如果您在 gradle 中使用了支持版本,请将firebase版本降到18.0.0. 否则您需要迁移到androidx.