错误:缺少google-services.json文件。没有它,Google服务插件无法正常运行。

12

我已经在我的应用程序中包含了google-services.json文件,但它仍然给我报错。

错误:执行任务“:app:processDebugGoogleServices”失败。

缺少文件google-services.json。没有它,Google服务插件无法正常工作。 搜索位置: C:\Users\vikas\AndroidStudioProjects\FireBaseFunctionality\app\src\debug\google-services.json C:\Users\vikas\AndroidStudioProjects\FireBaseFunctionality\app\google-services.json


你确定已经将它复制到项目的根目录了吗? - earthw0rmjim
是的,我已经复制到应用程序文件夹中。 - Vikas Sharma
7个回答

3

1
进入SDK管理器 --> SDK工具-->安装Play服务、USB工具和存储库。我用上述方法解决了同样的问题。
或者您可以更改谷歌服务的名称 google-services.json而不是 google-services(任意数字)。json

这在2019年是否是可行的解决方案? - IgorGanapolsky

1

只需要在 build.gradle 文件中更改以下行:

compile fileTree(dir: 'libs', include: ['*.jar'])

更改为

implementation fileTree(dir: 'libs', include: ['*.jar'])


1

对我有用的是:

然后按照https://console.firebase.google.com网站上的步骤在Android Studio中执行以下操作:

项目级别 build.gradle (/build.gradle):

buildscript {
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository

  }
  dependencies {
    ...
    // Add this line
    classpath 'com.google.gms:google-services:4.3.8'

  }
}

allprojects {
  ...
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository

    ...
  }
}

应用级别的 build.gradle (//build.gradle):

apply plugin: 'com.android.application'

// Add this line
apply plugin: 'com.google.gms.google-services'


dependencies {
  // Import the Firebase BoM
  implementation platform('com.google.firebase:firebase-bom:28.3.0')


  // Add the dependency for the Firebase SDK for Google Analytics
  // When using the BoM, don't specify versions in Firebase dependencies
  implementation 'com.google.firebase:firebase-analytics'


  // Add the dependencies for any other desired Firebase products
  // https://firebase.google.com/docs/android/setup#available-libraries
}

最后,在IDE中出现的栏中按“立即同步”:

0
去你的flutter sdk文件夹,用于构建应用程序。删除文件夹.pub-cache中的所有内容。现在运行pub-get命令并运行应用程序。

我应该在哪里找到 .pub-cache 呢? - K-Dawg
它在Flutter安装文件夹中,可能会被隐藏。 - JIJO J
谢谢,伙计,感激不尽! - K-Dawg

0
有时我们会把下载的文件复制到应用程序目录中,但是它的名称会发生改变。例如,googleservices.json 的名称可能会变成 googleservices(1).json,因此请确保文件名正确。

0

将您的googleservices(number).json更改为googleservices.json,没有数字,这对我有用,我遇到了同样的问题。


这并没有真正回答问题。如果您有不同的问题,可以通过点击提问来提出。如果您想在此问题获得新的答案时收到通知,可以关注此问题。一旦您拥有足够的声望,您还可以添加悬赏以吸引更多关注。- 来自审核 - Sercan Sebetçi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接