在Flutter应用程序中,我应该把Googleservices.json放在哪里才能解决“google-services.json丢失”的问题?

35

在将默认的Flutter应用程序与Firebase集成后,我尝试构建该应用程序时遇到了此错误。

我已将googleservices.json放在正确的位置。现在它说正在搜索不存在的位置。

src\debug\nullnull\google- services.json    

这个文件夹甚至不存在,我已经查过了,它没有出现。

Launching lib\main.dart on Phone in debug mode...
Configuration 'compile' in project ':app' is deprecated. Use 
'implementation' instead.
 registerResGeneratingTask is deprecated, use 
 registerGeneratedFolders(FileCollection)
 registerResGeneratingTask is deprecated, use 
 registerGeneratedFolders(FileCollection)
 registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot 
function without it. 
Searched Location: 
C:\Users\rober\Documents\VS\APPNAME\android\app\src\nullnull\debug\google- 
services.json
C:\Users\rober\Documents\VS\APPNAME\android\app\src\debug\nullnull\google- 
services.json
C:\Users\rober\Documents\VS\APPNAME\android\app\src\nullnull\google- 
services.json
C:\Users\rober\Documents\VS\APPNAME\android\app\src\debug\google- 
services.json
C:\Users\rober\Documents\VS\APPNAME\android\app\src\nullnullDebug\google- 
services.json
C:\Users\rober\Documents\VS\APPNAME\android\app\google-services.json

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- 
debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Gradle build failed: 1
Exited (sigterm)
2个回答

96

你需要将它放置在android/app目录下:

google-service.json的位置

同时,它应以google-services.json命名,破折号后面不要有空格。要重命名它,请右键单击它,然后点击Refactor>Rename。


1
哈哈,我感觉好傻。我把它放在了错误的目录下。谢谢你的说明和答案。 - Taio
@PeterHaddad 你也可以将它们放入 src/mainsrc/debug 源集中。 - Martin Zeitler
1
该图片显示它位于android/app/src目录中。 然而,它实际上应该位于android/app目录中! - guivho
11
实际上不是这样。如果你仔细看,你会注意到图片上并没有展开“src”目录。 - kokoko

0
通过将google-services.json添加到App_Resources/src目录中进行修复。

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