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

开启R8代码压缩后Firebase Auth报错:FirebaseAuthFallbackService类未找到

解决方案

这个问题是R8压缩过程中误移除/重命名了Firebase Auth依赖的服务类导致的,按以下步骤排查修复:

  • 首先统一Firebase组件版本:优先使用Firebase BoM管理所有Firebase相关依赖,避免跨版本不兼容问题,在app模块build.gradle的dependencies中添加BoM依赖示例:
dependencies {
  implementation platform('com.google.firebase:firebase-bom:32.7.0')
  // 引入Auth时不用单独写版本号,和BoM对齐
  implementation 'com.google.firebase:firebase-auth'
}
  • 手动添加混淆保留规则到app模块的proguard-rules.pro文件中:
# 保留Firebase Auth fallback服务
-keep class com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService { *; }
# 补充Firebase Auth通用混淆规则避免其他类被误删
-keep class com.google.firebase.auth.** { *; }
-keep class com.google.android.gms.auth.** { *; }
  • 若添加规则后仍报错,可在app模块的AndroidManifest.xml中手动注册该服务,覆盖库的默认声明解决Manifest合并异常问题:
<service
    android:name="com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService"
    android:enabled="true"
    android:exported="false"
    tools:replace="android:exported" />
  • 验证修复效果:先临时将app模块build.gradle中的minifyEnabled设为false打包运行,若不再报错则可确认是R8规则问题,再核对上述规则是否已正确加入生效。

内容的提问来源于stack exchange,提问作者Sumit yadu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.01 20:57:02