Firebase api初始化失败Ionic Framework

时间:2016-06-25 03:53:37

标签: android ionic-framework firebase

我试图在我的Ionic Framework中使用firebase。我为Android添加了google-services.json,为iOS添加了GoogleService-Info.plist。没有添加其他代码来进行初始化。

我能够在iOS上接收唯一的设备令牌,但不能在Android上接收。我检查了日志并记录firebase API initialisation failure,这会导致应用程序崩溃。附上日志,请协助。

06-25 09:06:34.798: D/FirebaseApp(17204): com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
06-25 09:06:34.805: E/FirebaseApp(17204): Firebase API initialization failure.
06-25 09:06:34.805: E/FirebaseApp(17204): java.lang.reflect.InvocationTargetException
06-25 09:06:34.805: E/FirebaseApp(17204):   at java.lang.reflect.Method.invoke(Native Method)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.FirebaseApp.zza(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.app.ActivityThread.installProvider(ActivityThread.java:5174)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.app.ActivityThread.installContentProviders(ActivityThread.java:4769)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4709)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.app.ActivityThread.-wrap1(ActivityThread.java)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.os.Handler.dispatchMessage(Handler.java:102)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.os.Looper.loop(Looper.java:148)
06-25 09:06:34.805: E/FirebaseApp(17204):   at android.app.ActivityThread.main(ActivityThread.java:5443)
06-25 09:06:34.805: E/FirebaseApp(17204):   at java.lang.reflect.Method.invoke(Native Method)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-25 09:06:34.805: E/FirebaseApp(17204): Caused by: java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/todevs.com.collegemate-2/base.apk)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.iid.zzg.zzeC(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.iid.zzg.<init>(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.iid.zzg.<init>(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.iid.zzd.zzb(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
06-25 09:06:34.805: E/FirebaseApp(17204):   ... 20 more
06-25 09:06:34.808: D/FirebaseApp(17204): com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
06-25 09:06:34.823: I/FA(17204): App measurement is starting up, version: 9080
06-25 09:06:34.823: I/FA(17204): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
06-25 09:06:34.852: D/FirebaseApp(17204): Initialized class com.google.android.gms.measurement.AppMeasurement.
06-25 09:06:34.852: I/FirebaseInitProvider(17204): FirebaseApp initialization successful
06-25 09:06:34.864: V/GoogleSignatureVerifier(17204): MBEmh/9iFBDAaTCK
06-25 09:06:34.876: D/XWalkLib(17204): Pre init xwalk core in todevs.com.collegemate.MainActivity
06-25 09:06:34.881: D/XWalkLib(17204): Reserve class class org.xwalk.core.XWalkPreferences to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve method setValue to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve class class org.xwalk.core.XWalkPreferences to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve method setValue to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve class class org.xwalk.core.XWalkPreferences to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve method setValue to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve class class org.xwalk.core.XWalkPreferences to todevs.com.collegemate.MainActivity
06-25 09:06:34.882: D/XWalkLib(17204): Reserve method setValue to todevs.com.collegemate.MainActivity
06-25 09:06:34.889: D/XWalkLib(17204): Reserve object class org.crosswalk.engine.XWalkCordovaView to todevs.com.collegemate.MainActivity
06-25 09:06:34.900: D/XWalkLib(17204): Reserve object class org.crosswalk.engine.XWalkCordovaResourceClient to todevs.com.collegemate.MainActivity
06-25 09:06:34.900: D/XWalkLib(17204): Reserve method setResourceClient to todevs.com.collegemate.MainActivity
06-25 09:06:34.901: D/XWalkLib(17204): Reserve object class org.crosswalk.engine.XWalkCordovaUiClient to todevs.com.collegemate.MainActivity
06-25 09:06:34.902: D/XWalkLib(17204): Reserve method setUIClient to todevs.com.collegemate.MainActivity
06-25 09:06:34.906: D/XWalkLib(17204): Reserve method setXWalkViewInternalVisibility to todevs.com.collegemate.MainActivity
06-25 09:06:34.906: D/XWalkLib(17204): Reserve method setSurfaceViewVisibility to todevs.com.collegemate.MainActivity
06-25 09:06:34.976: D/OpenGLRenderer(17204): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-25 09:06:35.012: V/StatusBar(17204): StatusBar: initialization
06-25 09:06:35.037: D/FCMPlugin(17204): ==> FCMPlugin initialize
06-25 09:06:35.039: D/AndroidRuntime(17204): Shutting down VM
06-25 09:06:35.039: E/AndroidRuntime(17204): FATAL EXCEPTION: main
06-25 09:06:35.039: E/AndroidRuntime(17204): Process: todevs.com.collegemate, PID: 17204
06-25 09:06:35.039: E/AndroidRuntime(17204): java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/todevs.com.collegemate-2/base.apk)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.iid.zzg.zzeC(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.iid.zzg.<init>(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.iid.zzg.<init>(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.iid.zzd.zzb(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.google.firebase.messaging.FirebaseMessaging.getInstance(Unknown Source)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.gae.scaffolder.plugin.FCMPlugin.initialize(FCMPlugin.java:34)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:57)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:172)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:98)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.PluginManager.init(PluginManager.java:87)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:116)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:144)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:214)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at todevs.com.collegemate.MainActivity.onCreate(MainActivity.java:32)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.Activity.performCreate(Activity.java:6259)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.ActivityThread.-wrap11(ActivityThread.java)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.os.Looper.loop(Looper.java:148)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at android.app.ActivityThread.main(ActivityThread.java:5443)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at java.lang.reflect.Method.invoke(Native Method)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
06-25 09:06:35.039: E/AndroidRuntime(17204):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

2 个答案:

答案 0 :(得分:0)

我重构了这个插件,并使其适用于Android和iOS上的离子。 https://github.com/guyromb/cordova-plugin-fcm-plus

确保您拥有适用于Android的最新Xcode或SDK工具(包括Google Play / services)。

答案 1 :(得分:0)

转到 project.properties 文件->

尝试更新您的依赖项以进行编译

TokenizeTest

com.google.firebase:firebase-messaging:9.0.2

我相信此错误已在9.0.0和9.0.2之间的补丁程序中修复