基于Support Library 28的项目集成Firebase Crashlytics构建失败
Let's break down your issues and fix them step by step—you're running into two key problems here: mismatched dependency group IDs/versions, and newer Firebase Crashlytics versions requiring AndroidX (which you can't migrate to right now). Here are two solid solutions tailored to your project:
Option 1: Use the Fabric-era Crashlytics (Compatible with Support Library 28)
Firebase's integrated Crashlytics (versions 17.x+) started relying on AndroidX, so if you can't migrate, you can fall back to the older Fabric-hosted Crashlytics (version 2.9.8 is the last stable release compatible with Support Library 28). You just need to fix your dependency group IDs and configuration:
1. Update your root build.gradle
- Remove the Firebase Crashlytics Gradle plugin and add the Fabric plugin instead
- Add the Fabric Maven repository to pull the dependency
Here's the modified buildscript block:
buildscript { ext.kotlin_version = '1.3.60' repositories { google() maven { url "http://dl.bintray.com/populov/maven" } jcenter() maven { url 'https://maven.fabric.io/public' } // Add Fabric's repo } ext { firebaseAnalytics = "16.3.0" firebasePerformanceMonitoring = "17.0.2" crashlyticsVersion = "2.9.8" // Fabric-era version } dependencies { classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.google.gms:google-services:4.3.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.firebase:perf-plugin:1.3.1' classpath 'io.fabric.tools:gradle:1.31.2' // Add Fabric Gradle plugin // Remove the old firebase-crashlytics-gradle plugin line } }
2. Update your app module's build.gradle
- Apply the Fabric plugin at the top of the file
- Replace your Firebase Crashlytics dependency with the Fabric one
Modified code:
// Add this at the very top apply plugin: 'io.fabric' dependencies { def supportLib_version = "28.0.0" implementation "com.android.support:support-v4:$supportLib_version" implementation "com.android.support:recyclerview-v7:$supportLib_version" implementation "com.android.support:design:$supportLib_version" // ... your other dependencies implementation "com.google.firebase:firebase-analytics:$firebaseAnalytics" implementation "com.google.firebase:firebase-perf:$firebasePerformanceMonitoring" implementation "io.fabric.sdk.android:fabric:$crashlyticsVersion" // Swap to Fabric dependency }
Option 2: Use the Last Firebase Crashlytics Version Compatible with Support Library
If you prefer to stick with the Firebase namespace for Crashlytics, 17.2.2 is the final stable version that doesn't force AndroidX. You'll need to match the Gradle plugin version to this SDK release:
1. Update your root build.gradle
- Set
firebaseCrashlyticsto17.2.2 - Use the matching Crashlytics Gradle plugin version (
1.2.10)
Modified buildscript block:
buildscript { ext.kotlin_version = '1.3.60' repositories { google() maven { url "http://dl.bintray.com/populov/maven" } jcenter() } ext { firebaseAnalytics = "16.3.0" firebasePerformanceMonitoring = "17.0.2" firebaseCrashlytics = "17.2.2" // Last Firebase version compatible with Support Library } dependencies { classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.google.gms:google-services:4.3.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.firebase:perf-plugin:1.3.1' classpath 'com.google.firebase:firebase-crashlytics-gradle:1.2.10' // Plugin matched to SDK version } }
2. Verify your app module dependency
Keep your existing Crashlytics dependency line, just ensure it's using the 17.2.2 version:
implementation "com.google.firebase:firebase-crashlytics:$firebaseCrashlytics"
Quick Notes
- Version
17.2.2is the absolute last Firebase Crashlytics release that works with Support Library 28—any version 18.x+ requires full AndroidX migration - While Fabric is no longer officially supported, its Crashlytics implementation will still send crash reports, making it a reliable stopgap for your large, multi-dev project that can't migrate yet
内容的提问来源于stack exchange,提问作者Jamal S

