Error integrating nativescript-plugin-firebase


#1

Hi
I am trying to integrate nativescript-plugin-firebase into my app. after following instructions to integrate the plugin I am not able to run the app. The following are some details

  1. the build is successful but on tns run android the app crashes with this error Error: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process org.nativescript.qbank. Make sure to call FirebaseApp.initializeApp(Context) first.

  2. The crash happens with the same message on both GenyMotion and the actual device. Both have play services installed.

  3. google-services.json is there in both platforms/android AND app/App_Resources/Android

  4. reinstalled Google Play Services APK.

Was not able to get the app to run inspite of all these changes.

here are the error messages:

Total time: 39.133 secs
Project successfully built
Successfully deployed on device with identifier ‘cdb18c57’.
Successfully deployed on device with identifier ‘192.168.165.101:5555’.
02-07 07:45:40.466 23755 23755 W System.err: com.tns.Runtime.callJSMethodNative(Native Method)
02-07 07:45:40.466 23755 23755 W System.err: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
02-07 07:45:40.466 23755 23755 W System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
02-07 07:45:40.466 23755 23755 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1047)
02-07 07:45:40.466 23755 23755 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1028)
02-07 07:45:40.466 23755 23755 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1018)
02-07 07:45:40.467 23755 23755 W System.err: com.tns.Runtime.callJSMethodNative(Native Method)
02-07 07:45:40.467 23755 23755 W System.err: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
02-07 07:45:40.467 23755 23755 W System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
02-07 07:45:40.467 23755 23755 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1047)
02-07 07:45:40.467 23755 23755 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1028)
02-07 07:45:40.467 23755 23755 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1018)
02-07 07:45:40.467 23755 23755 W System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
02-07 07:45:40.467 23755 23755 W System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
02-07 07:45:40.467 23755 23755 W System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
02-07 07:45:40.467 23755 23755 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1047)
02-07 07:45:40.467 23755 23755 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1028)
02-07 07:45:40.467 23755 23755 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1018)
02-07 18:15:43.105 14542 14542 W System.err: com.tns.Runtime.callJSMethodNative(Native Method)
02-07 18:15:43.105 14542 14542 W System.err: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
02-07 18:15:43.105 14542 14542 W System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
02-07 18:15:43.105 14542 14542 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1047)
02-07 18:15:43.105 14542 14542 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1028)
02-07 18:15:43.105 14542 14542 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1018)
02-07 18:15:43.106 14542 14542 W System.err: com.tns.Runtime.callJSMethodNative(Native Method)
02-07 18:15:43.106 14542 14542 W System.err: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
02-07 18:15:43.106 14542 14542 W System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
02-07 18:15:43.106 14542 14542 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1047)
02-07 18:15:43.106 14542 14542 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1028)
02-07 18:15:43.106 14542 14542 W System.err: com.tns.Runtime.callJSMethod(Runtime.java:1018)
02-07 18:15:43.107 14542 14542 W System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
02-07 18:15:43.107 14542 14542 W System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
02-07 18:15:43.107 14542 14542 W System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
02-07 18:15:43.107 14542 14542 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1047)
02-07 18:15:43.107 14542 14542 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1028)
02-07 18:15:43.107 14542 14542 W System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1018)


#2

one thing which comes to me from this is only that u skipped init of firebase https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/README.md#start-up-wiring


#3

I have several examples of how to use Firebase if you need code samples: http://github.com/jlooper/giftler and http://github.com/jlooper/practicebuddy


#4

Fixed it. Deleted node modules and the platform and then reinstalled them and then reinstalled the the plugin. Working now!


#5

@anuragd7 Hi, I have the exact same issue, I’ve done exactly what you said…deleted the node_modules, deleted the platform, then reinstalled the platform with the modules and then reinstalled the firebase plugin again. After doing all that it gave me an error saying that gradlew.bat failed so I fixed that by going into ~/platform/android and did ./gradlew clean. Then I finally tried to run the app in android again and it brings me back to the original problem the first error that started this thing, can you please help me, what am I doing wrong here?

Thanks


#6

Please re-add the platform, and without doing ./gradlew clean build and run the app. Should you face the same crash, open the adb logcat (type in adb logcat), which will likely reveal more information than what the CLI spits out about the crash. Feel free to share the logcat if you can’t decipher it.


#7

Hey @Pete.K, so I did that and it told me that the ‘:processF0F1DebugGoogleServices’ failed (I can put up the logcat if you want). The google repository, the google play services, and the android support repository are all updated. Also after adding the android platform back I added the line apply plugin: “com.google.gms.google-services” to the end of the build.gradle and I still have the same issue. :confused:


#8

@samwil yes, please share the logcat. If you could isolate a sample by taking out any sensitive information, and sharing it, that might also help.


#9

@Pete.K, here is the document after doing adb logcat:

I feel like that is not the whole document but I’m not sure, let me know.


#10

Hey @samwil I was left with the impression that the problem occurs when the application’s running, but I don’t see any relevant logs in there. It’s mostly system log garbage.


#11

so sorry @Pete.K, can you take a look at this file, this is the correct one I’m sorry!


#12

Thank you @Pete.K, it’s finally solved (I ran into a different error but has nothing to do with gradle) in the nativescript-plugin-firebase github readme it says to add:

// /app/App_Resources/Android/app.gradle

project.ext {
googlePlayServicesVersion = “+”
}

All I had to do is delete it and then removed the android platform then added it back and application works using the firebase plugin…for now, lol