IONIC 2,如何匹配Google Service,PushNotifications和Firebase的版本

时间:2017-10-19 09:10:11

标签: android cordova firebase ionic2 firebase-cloud-messaging

我遇到了ionic2 / cordova(再次)。我不知道如何匹配以下版本:  com.google.android.gmscordova-plugin-firebasephonegap plugin push

在编译时,我有以下错误:

BUILD FAILED

Total time: 4.038 secs
Error: /home/thor/Projects/App_CDP/platforms/android/gradlew: Command failed with exit code 1 Error output: /home/thor/Projects/App_CDP/platforms/android/src/com/adobe/phonegap/push/FCMService.java:71: error: cannot access zza
    String from = message.getFrom();
                         ^
 class file for com.google.android.gms.common.internal.safeparcel.zza not found

据我所知,这是因为Google服务和PushNotifications之间存在版本差异。 我在gradle.build中有以下依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
     compile "com.facebook.android:facebook-android-sdk:4.+"
     compile "com.google.android.gms:play-services-maps:11.+"
     compile "com.google.android.gms:play-services-location:11.+"
     compile "com.android.support:support-v13:25.1.0"
     compile "me.leolin:ShortcutBadger:1.1.17@aar"
     compile "com.google.firebase:firebase-messaging:11.0.1"
     // SUB-PROJECT DEPENDENCIES END
}

问题是这个文件是自动生成的,所以我无法更改它,而且cordova插件很痛苦。

这是我的插件列表:

$ ionic cordova plugins
> cordova plugin ls
✔ Running command - done!
com.googlemaps.ios 2.4.0 "Google Maps SDK for iOS"
cordova-android-play-services-gradle-release 1.1.1 "cordova-android-play-
services-gradle-release"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-googlemaps 1.4.5 "cordova-googlemaps-plugin"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 2.0.0 "PushPlugin"

这是我的版本:

$ ionic -v
3.13.1
$ cordova -v
7.1.0

1 个答案:

答案 0 :(得分:0)

谢谢,

我在这里得到了解决方案:

第1步:删除现有的phonegap-plugin-push

ionic cordova plugin rm phonegap-plugin-push

步骤2:添加版本的同一插件:1.10.5

ionic cordova plugin add phonegap-plugin-push@1.10.5 --variable SENDER_ID="xxxxxxxxxxx"

步骤3:删除平台android而不是添加它。

ionic cordova platform rm android

ionic cordova platform add android

第4步:最后为android创建一个构建

ionic cordova build android

如果此步骤不起作用,请参阅 /project_name/platforms/android/project.properties

cordova.system.library.7=com.google.android.gms:play-services-gcm:11+

玩得开心:)