科尔多瓦插件firebase编译问题

时间:2019-07-13 09:19:18

标签: android firebase cordova ionic-framework

我正在尝试使用Firebase本机插件创建Ionic应用程序。

我首先创建离子应用程序: ionic start

然后我添加Firebase插件:
ionic cordova plugin add cordova-plugin-firebase npm install @ionic-native/firebase

之后,我尝试添加android平台: ionic cordova build android

我有这个错误:

> Task :app:fabricGenerateResourcesDebug FAILED
ERROR - Crashlytics Developer Tools error.
java.lang.IllegalArgumentException: Crashlytics found an invalid API key: null. 

我的插件列表cordova plugin list

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-firebase 2.0.5 "Google Firebase Plugin"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

如果我使用android studio,则会遇到相同的错误: Crashlytics发现无效的API密钥:null。

所以我用了这篇文章:Crashlytics found an invalid API key - AndroidStudio build

此后,我得到此错误:错误:找不到符号类NotificationManagerCompat。
因此,我在应用程序的builde.gradle中添加了依赖项implementation 'com.android.support:support-compat:27.+'

但是我仍然遇到2个错误:

#android/app/src/main/java/org/apache/cordova/firebase/FirebasePlugin.java
error: method getByteArray in class FirebaseRemoteConfig cannot be applied to given types;
required: String
found: String,String
reason: actual and formal argument lists differ in length
#android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginInstanceIDService.java
error: cannot find symbol class FirebaseInstanceIdService
error: method does not override or implement a method from a supertype

我如何才能使离子应用程序与Firebase(firestore,auth和云消息传递)一起使用?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我还记得与Firebase相关的插件存在无尽的问题,但是我最终设法使它们与cordova@7.1.0cordova-android@6.3.0一起使用。如果我没记错的话,我通过switching the Gradle version至4.1解决了其中一个问题。

我只有cordova-plugin-firebase-authentication插件,它取决于cordova-support-google-services,您似乎尚未安装。您应该仔细检查插件是否需要它。