使用Firebase过程中出现的异常

本文介绍了两种常见的Gradle编译错误:一是由于依赖声明格式不正确导致的未知属性'compile'错误;二是缺失google-services.json文件导致的任务失败。文中提供了具体的解决步骤,帮助开发者快速定位并解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、Could not get unknown property 'compile' for object

编译器报下面的错误,请检查build.gradle并调整格式

Error:(30, 0) Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.


原因:studio添加代码的位置可能不对,或者改变了代码的格式,造成studio识别不了


解决方法:修改错误的代码格式,如上图compile的位置不对,需要调整




二、The Google Service Plugin cannot function without it

Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Error:Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  E:\MyApplication3\app\src\debug\google-services.json
  E:\MyApplication3\app\google-services.json


原因:缺少google-services.json文件,该文件是在Firebase服务端创建项目后自动生成并下载的

解决办法:在服务端https://console.firebase.google.com/?pli=1注册登陆并创建工程,点击项目所需要的模块下,然后点击开始应用,按提示步骤执行,将中间生成的google-service.json文件拷贝到应用的根目录



参考资料:https://developers.google.com/identity/sign-in/android/start-integrating

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值