You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

引入firebase-ui-database依赖报Corrupt serialized resolution错误如何解决

解决方案

该报错由Firebase UI依赖版本与项目中已引入的原生Firebase组件版本不兼容导致,可按以下步骤修复:

  • 方案1:使用Firebase BOM统一管理依赖版本(推荐)
    BOM可以自动匹配所有Firebase相关组件的兼容版本,无需手动指定每个依赖的版本号,修改dependencies区块如下:
    dependencies {
        // 其他非Firebase依赖保留不变
        implementation 'androidx.appcompat:appcompat:1.3.1'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
        implementation 'androidx.multidex:multidex:2.0.1'
        implementation "androidx.recyclerview:recyclerview:1.2.1"
        implementation "androidx.cardview:cardview:1.0.0"
    
        // 引入Firebase BOM统一管理版本,对应Firebase UI 8.0.0的兼容BOM版本为28.0.1
        implementation platform('com.google.firebase:firebase-bom:28.0.1')
        // 以下Firebase依赖无需单独指定版本号
        implementation 'com.google.firebase:firebase-analytics'
        implementation 'com.google.firebase:firebase-database'
        implementation 'com.google.firebase:firebase-firestore'
        implementation 'com.firebaseui:firebase-ui-database:8.0.0'
    
        // 测试依赖保留不变
        testImplementation 'junit:junit:4.+'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    }
    
  • 方案2:降低Firebase UI版本
    若不想改动现有Firebase依赖版本,可直接使用注释中的7.2.0版本Firebase UI,替换现有8.0.0版本的依赖即可:
    // 注释掉8.0.0版本
    // implementation 'com.firebaseui:firebase-ui-database:8.0.0'
    // 启用7.2.0版本
    implementation 'com.firebaseui:firebase-ui-database:7.2.0'
    
  • 完成配置后清理缓存重建项目
    点击Android Studio顶部菜单栏 File -> Invalidate Caches / Restart,选择Invalidate and Restart,重启后同步Gradle,再执行Build -> Clean Project和Build -> Rebuild Project即可消除报错。

额外优化建议:你配置的plugins区块中存在重复注释的com.google.gms.google-services声明,可直接删除无用的注释行。

内容的提问来源于stack exchange,提问作者Yasantha Mihiran

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 09:18:00