求助:Play Store应用存在两处Crashlytics未捕获的严重崩溃问题
分析与解决方案
首先看你的崩溃日志,两处崩溃的核心都是在art::JavaVMExt::AddGlobalRef调用时触发了系统abort,第二处日志更是明确指向了Google Play Services的位置服务模块(com.google.android.gms.internal.location.zzaz.zza),结合你提到的依赖不匹配怀疑,确实版本不一致的Google服务依赖是大概率原因。
问题根源
你的依赖配置里存在几个关键问题:
- Google Play Services模块版本不一致:
play-services-maps:16.1.0和play-services-location:16.0.0版本差了0.1,这类细微的版本差异会导致内部类、JNI接口不兼容,进而触发底层引用错误。 - 使用了已停止维护的Support Library(
appcompat-v7:28.0.0),旧Support库与较新的Google服务依赖容易出现兼容性问题。 - Crashlytics版本过旧(2.10.0),旧版本可能无法捕获这类底层JNI崩溃,也和新的Firebase服务不兼容。
具体修复步骤
1. 统一Google服务与Firebase依赖版本(推荐使用BOM管理)
Google提供了Firebase BOM(Bill of Materials)来自动统一所有Firebase和Google Play Services依赖的版本,避免手动匹配出错。修改你的dependencies块如下:
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) // 迁移到AndroidX(必须,因为Support库已废弃) implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.core:core:1.12.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // 使用Firebase BOM统一版本 implementation platform('com.google.firebase:firebase-bom:32.8.0') implementation 'com.google.firebase:firebase-core' implementation 'com.google.firebase:firebase-crashlytics' // Google Play Services模块无需指定版本,由BOM自动管理 implementation 'com.google.android.gms:play-services-maps' implementation 'com.google.android.gms:play-services-location' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } apply plugin: 'com.google.gms.google-services' // 添加Crashlytics插件(如果之前没加) apply plugin: 'com.google.firebase.crashlytics'
2. 迁移到AndroidX
如果你的项目还在使用Support Library,必须迁移到AndroidX:
- 在
gradle.properties中添加以下配置:android.useAndroidX=true android.enableJetifier=true - Jetifier会自动将旧的Support库依赖转换为AndroidX,减少手动修改成本。
3. 清理项目缓存并重新构建
执行以下操作确保旧缓存被清除:
- Android Studio中点击
File > Invalidate Caches... > Invalidate and Restart - 终端执行
./gradlew clean build(Windows用gradlew clean build)
4. 验证崩溃捕获
更新后重新打包上传到Play Store内部测试轨道,测试是否还会出现崩溃,同时Crashlytics应该能正常捕获到相关错误信息。
临时兼容方案(若暂时无法迁移AndroidX)
如果暂时不想迁移AndroidX,至少要保证所有Google Play Services模块版本一致:
// 将maps和location统一为相同版本 implementation 'com.google.android.gms:play-services-maps:17.0.1' implementation 'com.google.android.gms:play-services-location:17.0.1' // 同时更新Firebase和Crashlytics版本到兼容Support库的最新版 implementation 'com.google.firebase:firebase-core:17.0.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.11.1'
这种底层JNI崩溃通常是由于依赖版本不兼容导致的类加载冲突或JNI接口不匹配,统一版本后应该能解决问题。
内容的提问来源于stack exchange,提问作者Dan C
相关产品推荐
相关产品推荐

