更新Firebase库后出现‘com.google.android.gms.internal.zzbck类文件未找到’错误
解决「class file for com.google.android.gms.internal.zzbck not found」错误
嘿,我之前也碰到过一模一样的问题!这个错误大多是Firebase依赖和Google Play Services库版本不兼容、依赖版本不一致,或者缓存/构建配置出了问题导致的。给你几个亲测有效的解决办法:
1. 确保所有Firebase依赖版本完全统一
你现在用的是12.0.1版本,一定要保证所有Firebase相关依赖的版本号完全一致,哪怕有一个版本不一样都可能触发这个错误。比如检查你的Module级build.gradle:
compile 'com.google.firebase:firebase-invites:12.0.1' compile 'com.google.firebase:firebase-core:12.0.1' compile 'com.google.firebase:firebase-auth:12.0.1' compile 'com.google.firebase:firebase-database:12.0.1' compile 'com.google.firebase:firebase-crash:12.0.1'
另外如果项目里用到了com.google.android.gms开头的依赖(比如play-services-auth),也要和Firebase版本保持一致。
2. 匹配Google服务插件版本
在Project级别的build.gradle里,com.google.gms:google-services插件的版本要和Firebase版本对应。12.0.1版本的Firebase适配的插件版本是3.2.1,你可以检查一下:
buildscript { dependencies { classpath 'com.google.gms:google-services:3.2.1' // 和Firebase 12.0.1匹配 // 要是后续升级Firebase,插件版本也要同步升级哦 } }
3. 清理缓存并重建项目
有时候旧的构建缓存会搞出这种奇怪的问题,按这个步骤操作:
- 点击Android Studio顶部菜单栏的
Build->Clean Project - 接着点击
Build->Rebuild Project - 要是还不行,手动删除项目根目录的
.gradle文件夹和Module下的build文件夹,再重新同步项目
4. 检查Multidex配置
你已经加了multidex依赖,但还要确保配置到位:
- 如果你的Application类继承自
Application,改成继承MultiDexApplication:
public class MyApp extends MultiDexApplication { // 你的业务代码 }
- 要是有自定义的Application类,就在
attachBaseContext里加这段代码:
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }
- 还要在Module的build.gradle里开启multidex:
android { defaultConfig { multiDexEnabled true } }
5. 考虑升级到更稳定的Firebase版本
12.0.1是比较旧的版本了,Google后续修复了很多兼容性问题。如果项目允许,建议升级到最新的稳定版(比如20.x系列,根据你的Android SDK版本适配),升级时记得所有Firebase依赖和Google服务插件版本同步更新。
内容的提问来源于stack exchange,提问作者Rohit
相关产品推荐
相关产品推荐

