简体   繁体   English

由于文件 google-services.json 丢失,无法构建 flutter apk

[英]Can't build flutter apk because of File google-services.json is missing

i have a problem when i try to build flutter apk i get this error even tho i have the right file with the right name in the right place i tried deleting the pub cash folder from flutter folder but still the same当我尝试构建 flutter apk 时遇到问题,即使我在正确的位置有正确名称的正确文件,我也会收到此错误我尝试从 flutter 文件夹中删除 pub cash 文件夹但仍然相同

FAILURE: Build failed with an exception. FAILURE:构建失败并出现异常。

  • What went wrong: Execution failed for task ':cloud_firestore:processReleaseGoogleServices'.出了什么问题:任务“:cloud_firestore:processReleaseGoogleServices”执行失败。

File google-services.json is missing.文件 google-services.json 丢失。 The Google Services Plugin cannot function without it.没有它,Google 服务插件不能 function。 Searched Location: AppData\Local\Pub\Cache\hosted\pub.dartlang.org\cloud_firestore-3.1.18\android\src\release\google-services.json AppData\Local\Pub\Cache\hosted\pub.dartlang.org\cloud_firestore-3.1.18\android\src\google-services.json AppData\Local\Pub\Cache\hosted\pub.dartlang.org\cloud_firestore-3.1.18\android\google-services.json搜索位置:AppData\Local\Pub\Cache\hosted\pub.dartlang.org\cloud_firestore-3.1.18\android\src\release\google-services.json AppData\Local\Pub\Cache\hosted\pub.dartlang。 org\cloud_firestore-3.1.18\android\src\google-services.json AppData\Local\Pub\Cache\hosted\pub.dartlang.org\cloud_firestore-3.1.18\android\google-services.json

  • Try:尝试:

Run with --stacktrace option to get the stack trace.使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.使用 --info 或 --debug 选项运行以获得更多日志 output。 Run with --scan to get full insights.运行 --scan 以获得完整的见解。

BUILD FAILED in 1m 7s Running Gradle task 'assembleRelease'... 68.6s Gradle task assembleRelease failed with exit code 1 Process finished with exit code 1 BUILD FAILED in 1m 7s Running Gradle task 'assembleRelease'... 68.6s Gradle task assembleRelease 失败,退出代码 1 进程完成,退出代码 1

flutter clean
flutter pub get

It helped me in my case在我的情况下它帮助了我

Happened to me before and the reason was that there was a space in the file name以前发生在我身上,原因是文件名中有空格
"google-services.json" “谷歌服务.json”

So double-check if the file name is exactly like this "google-services.json" and the path for the file is APP_NAME\android\app\google-services.json因此,请仔细检查文件名是否与“google-services.json”完全相同,文件的路径是否为APP_NAME\android\app\google-services.json

If everything is correct run flutter clean then flutter pub get如果一切正常运行flutter clean然后flutter pub get

In my case, it was similar to your 'BUILD FAILURE'就我而言,它类似于您的“BUILD FAILURE”
Compiler tried to find ' google-services.json ' in ' \flutter\.pub-cache '编译器试图在“ \flutter\.pub-cache ”中找到“ google-services.json

So I solved it by clearing the cache folder.所以我通过清除缓存文件夹来解决它。 (see below) (见下文)


Solution解决方案

Step 1步骤1

Clear the cache清除缓存

Clear the global PUB_CACHE:清除全局 PUB_CACHE:

flutter pub cache clean

or或者

Go to that path and directly delete the cache. Go 到那个路径,直接删除缓存。

Step 2第2步

Get packages and run获取包并运行

flutter pub get

and

flutter run



I hope my answer is helpful.我希望我的回答有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM