ERROR: Failed to resolve: com.google.firebase:firebase-crash:17.2.2

ERROR: Failed to resolve: com.google.firebase:firebase-crash:17.2.2

我正在尝试更新项目中的 google 和 firebase SDK 库以解决 的问题,但在同步

后出现错误
ERROR: Failed to resolve: com.google.firebase:firebase-crash:17.2.2

合并清单上的这个错误

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:28:5-422:19 to override.

这是我的 firebase 和 google 依赖项

    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-crash:17.2.2'
    implementation 'com.google.firebase:firebase-config:19.1.1'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'

    implementation 'com.google.android.gms:play-services-base:17.1.0'
    implementation 'com.google.android.gms:play-services-analytics:16.0.8'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'

    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.google.firebase:firebase-ads:18.3.0'
    implementation 'com.google.firebase:firebase-messaging:20.1.0'

使用以下依赖项:

implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'

并更新您的应用程序以使用 AndroidX:

Upgrade com.android.tools.build:gradle to v3.2.1 or later.

Upgrade compileSdkVersion to 28 or later.

Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

https://developer.android.com/jetpack/androidx/migrate


更新:

您现在可以使用以下依赖版本:

dependencies {
    // Recommended: Add the Firebase SDK for Google Analytics.
    implementation 'com.google.firebase:firebase-analytics:17.5.0'

    // Add the Firebase Crashlytics SDK.
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
}

如果您在添加 firebase-crashlytics 时遇到问题,请查看以下文档:

https://firebase.google.com/docs/crashlytics/get-started?platform=android

https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android

按照以下文档将 crashlytics 集成到您的项目中

https://firebase.google.com/docs/crashlytics/get-started?platform=android&authuser=0#add-sdk

项目要求

  • compileSdkVersion 29 或更高版本
  • Gradle版本com.android.tools.build:gradle:4.0.1
  • 如果您的项目不包含 androidX,则将您的项目迁移到 AndroidX

https://developer.android.com/jetpack/androidx/migrate

尝试将 com.crashlytics.sdk.android:crashlytics:17.2.2 更改为 com.google.firebase:firebase-crashlytics:17.2.1

这对我有用。

在 11 月弃用之前添加新的 Firebase Crashlytics 的步骤

来自您的 build.gradle 项目模块

    // Remove Fabric's Maven repository from allProjects.
    maven { url 'https://maven.fabric.io/public' }

    // Remove the Fabric Gradle plugin.
    classpath 'io.fabric.tools:gradle:1.31.2'

    // Add the Firebase Crashlytics Gradle plugin.
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'

来自您的 build.gradle 应用程序模块

// Remove the Fabric plugin.
apply plugin: 'io.fabric'

// Add the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'


dependencies {
  // Remove the Fabric Crashlytics SDK.
  implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

  // Add the Firebase Crashlytics SDK.
  implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
}

// Remove 注释的链接不应在您的 gradle 配置中,而是添加建议的依赖项和插件

来源:https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android

引用彼得斯的回答,你还应该

Upgrade com.android.tools.build:gradle to v3.2.1 or later.

Upgrade compileSdkVersion to 28 or later.

Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:29.0.0')

    // Declare the dependencies for the Crashlytics and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'

Refrence