[英]File google-services.json is missing. The Google Services Plugin cannot function without it ionic 3
I am using FCM for push notification I always get this error message我正在使用 FCM 进行推送通知我总是收到此错误消息
"File google-services.json is missing. The Google Services Plugin cannot function without it ionic 3"
“文件 google-services.json 丢失。没有它 ionic 3,Google 服务插件无法运行”
on phone I have placed my google-services.json on every folder and nothings working在电话上,我已将 google-services.json 放在每个文件夹中,但没有任何工作
Fist of all you need to download google-services.json:首先你需要下载 google-services.json:
( https://support.google.com/firebase/answer/7015592 ) ( https://support.google.com/firebase/answer/7015592 )
Ok now you have to install cordova-support-google-services:好的,现在您必须安装cordova-support-google-services:
cordova plugin add cordova-support-google-services --save
Then, you have to put the google-services.json in the root of your project (outside www folder, at the same level), and then the resource-file tag will copy it to platforms/android/app/然后,你必须把google-services.json放在你项目的根目录下(www文件夹外,同级),然后resource-file标签将其复制到platforms/android/app/
Next, put in the config.xml接下来,放入config.xml
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
...
</platform>
Note: if you use cordova-android below version 7 specify instead:注意:如果您使用低于版本 7 的cordova-android,请改为指定:
target="google-services.json"
目标=“google-services.json”
Now try again to build!现在再次尝试构建!
As mentioned before google-services.json
needs to be copied to the proper location.如前所述,需要将
google-services.json
复制到正确的位置。 the location changed recently to app/google-services.json
.位置最近更改为
app/google-services.json
。 So the config.xml
needs to be adapted accordingly to所以
config.xml
需要相应地适应
<resource-file src="google-services.json" target="app/google-services.json" />
Lets' assume you put the google-services.json in src/app folder So relativly to your ionic project it is located at src/app/google-services.json让我们假设您将 google-services.json 放在 src/app 文件夹中 所以相对于您的 ionic 项目,它位于src/app/google-services.json
Now, to be sure it will be copied to the correct location of the build, you have to add a line of code to the config.xml file.现在,为了确保将其复制到构建的正确位置,您必须向 config.xml 文件中添加一行代码。
<resource-file src="src/app/google-services.json" target="app/google-services.json" />
Note that the src property of this line should reflect the relative path of the google-service.json file accordingly.请注意,此行的src属性应相应地反映 google-service.json 文件的相对路径。
That's as simple as that就这么简单
Place the google-services.json
file in your project's root and make sure it will be copied to the www
directory by adding this line to the config.xml
file (between the <platform name="android">...</platform>
tags):将
google-services.json
文件放在项目的根目录中,并通过将此行添加到config.xml
文件(在<platform name="android">...</platform>
之间)将其复制到www
目录<platform name="android">...</platform>
标签):
<resource-file src="google-services.json" target="google-services.json" />
then run ionic cordova prepare android
again.然后再次运行
ionic cordova prepare android
。
I have placed google-services.json
in Platforms/Android/
folder and run ionic cordova build android
.我已将
google-services.json
放在Platforms/Android/
文件夹中并run ionic cordova build android
。 Its working.它的工作。
You have to copy the google-services.json file into platforms/android/app folder.您必须将 google-services.json 文件复制到平台/android/app 文件夹中。 Executing a android run will work fine.
执行 android run 会正常工作。
(You can download the google-services.json from firbase project settings. (您可以从 firbase 项目设置下载 google-services.json。
将您的google-services.json
复制到您的ionicProject/src
然后再次尝试删除并重新安装ionic-firebase
插件。
Add google-services.json file where the config.xml file is在 config.xml 文件所在的位置添加google-services.json文件
Then add this line to the config.xml file然后将这一行添加到 config.xml 文件中
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
Then go to Project/platforms/android and add the google-services.json file然后转到Project/platforms/android并添加google-services.json文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.