集成Facebook登录时出现无法列出com.facebook.android:facebook-login版本的问题
解决Facebook登录依赖解析失败问题
问题原因
- JCenter仓库已停止服务,Gradle尝试从JCenter拉取
com.facebook.android:facebook-login的版本元数据时超时。 - 使用
latest.release动态版本号会触发Gradle查询仓库元数据文件,而JCenter无法访问直接导致解析失败。
修复步骤
1. 替换为具体依赖版本号
将Android项目build.gradle(Module级别)中dependencies块里的动态版本替换为稳定的具体版本(推荐使用适配compileSdkVersion 33的15.2.0版本):
dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:29.2.1') implementation 'com.google.firebase:firebase-analytics-ktx' // 替换动态版本为具体稳定版 implementation 'com.facebook.android:facebook-login:15.2.0' }
2. 确认仓库配置有效性
保持repositories配置仅包含活跃维护的仓库,不要添加已废弃的JCenter:
repositories { google() mavenCentral() }
3. 清理缓存并重新构建
执行以下命令清理项目缓存,避免残留的无效依赖配置影响构建:
flutter clean flutter pub get cd android && ./gradlew clean build
额外提示
- 尽量避免使用
latest.release这类动态版本号,不仅会增加依赖解析失败的概率,还可能引入未测试过的版本导致兼容性问题。 - 若需要确认适配版本范围,可查看
flutter_login_facebook的官方文档,匹配其声明兼容的Facebook SDK版本。
内容的提问来源于stack exchange,提问作者Ravin Laheri
相关产品推荐
相关产品推荐

