【发布时间】:2017-08-07 22:30:24
【问题描述】:
由于我没有 Mac 和 iPhone,我唯一的选择是使用 Ionic Cloud 来构建我的原生二进制文件。但是,首先我想玩一下它,看看它如何与 android 版本一起工作。
我的应用程序使用https://github.com/fechanique/cordova-plugin-fcm
所以我可以使用ionic cordova build android 构建应用程序并在我的模拟器上运行它而不会出现任何问题。但是,如果我执行 ionic package build android 然后 ionic package info 我收到消息说我的构建失败了。
使用ionic package BUILD_ID 检查此失败我收到此消息:
Error: cordova-plugin-fcm: You have installed platform android but file 'google-services.json' was not found in your Cordova project root folder.
所以,看起来我的google-services.json 没有上传到云端。所以搜索我发现很少有人有同样问题的帖子,但他们都没有为我提供解决方案。我还发现了这个:
https://cordova.apache.org/docs/en/latest/config_ref/index.html#resource-file
所以我试图告诉 ionic 将这个 google-services.json 文件包含在这样的包中:
<?xml version='1.0' encoding='utf-8'?>
<widget id="me.citybeep.partnerapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<!-- ... -->
<platform name="android">
<!-- ... -->
<resource-file src="google-services.json" target="platforms/android/google-services.json" />
</platform>
<!-- ... -->
<engine name="android" spec="^6.2.3" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-fcm" spec="^2.1.2" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="cordova-sqlite-storage" spec="^2.0.4" />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="^0.8.5" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
</widget>
也试过这个:
<resource-file src="google-services.json" target="google-services.json" />
但我们没有成功,但是现在我收到另一条消息:
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: me.citybeep.partnerapp
Name: City_Beep_Partner
Activity: MainActivity
Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android@6.2.3
Error: Source path does not exist: google-services.json
我认为这个错误只是 google-services.json 没有上传。
我现在真的很依赖这个插件,目前还不能使用 Ionic Push 通知...
那么有没有办法告诉 ionic 在上传到云时包含这个 google-services.json 文件(以及 .plist 文件)。我再说一遍,google-services.json 文件或我的 firebase 项目没有问题,因为在我的机器上执行构建时一切正常。
【问题讨论】:
标签: ios cordova ionic-framework ionic2 ionic-cloud