Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push notifications: NPE if google-services.json is not found #290

Open
jperedadnr opened this issue Oct 29, 2021 · 2 comments
Open

Push notifications: NPE if google-services.json is not found #290

jperedadnr opened this issue Oct 29, 2021 · 2 comments

Comments

@jperedadnr
Copy link
Contributor

google-services.json is needed for Android, but if it is not present it causes a NPE:

10-29 12:31:11.799  7338 11290 D GraalCompiled: WARNING: Failed to read google-services.json. Make sure to add the file to the folder: src/android/resources
10-29 12:31:11.799  7338 11290 D GraalCompiled: java.lang.NullPointerException
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at org.glassfish.json.UnicodeDetectingInputStream.fillBuf(UnicodeDetectingInputStream.java:65)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at org.glassfish.json.UnicodeDetectingInputStream.detectEncoding(UnicodeDetectingInputStream.java:104)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at org.glassfish.json.UnicodeDetectingInputStream.<init>(UnicodeDetectingInputStream.java:51)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at org.glassfish.json.JsonParserImpl.<init>(JsonParserImpl.java:71)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at org.glassfish.json.JsonReaderImpl.<init>(JsonReaderImpl.java:49)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at org.glassfish.json.JsonProviderImpl.createReader(JsonProviderImpl.java:112)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at javax.json.Json.createReader(Json.java:201)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at com.gluonhq.attach.pushnotifications.impl.AndroidPushNotificationsService.readGoogleServicesConfiguration(AndroidPushNotificationsService.java:97)
10-29 12:31:11.799  7338 11290 D GraalCompiled: 	at com.gluonhq.attach.pushnotifications.impl.AndroidPushNotificationsService.register(AndroidPushNotificationsService.java:84)

This should be avoided.

@tiainen
Copy link
Contributor

tiainen commented Oct 29, 2021

This exception is already correctly handled. The actual fatal crash happens later on when trying to initialize Firebase in DalvikPushNotificationsService.initializeFirebase():

10-29 12:31:11.799  7338 11292 F com.d: java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.IllegalArgumentException: ApplicationId must be set.
10-29 12:31:11.799  7338 11292 F com.d: java_vm_ext.cc:577]   at java.lang.String com.google.android.gms.common.internal.Preconditions.checkNotEmpty(java.lang.String, java.lang.Object) ((null):8)
10-29 12:31:11.799  7338 11292 F com.d: java_vm_ext.cc:577]   at com.google.firebase.FirebaseOptions$Builder com.google.firebase.FirebaseOptions$Builder.setApplicationId(java.lang.String) (com.google.firebase:firebase-common@@19.3.0:87)
10-29 12:31:11.799  7338 11292 F com.d: java_vm_ext.cc:577]   at void com.gluonhq.helloandroid.DalvikPushNotificationsService.initializeFirebase(java.lang.String, java.lang.String, java.lang.String, java.lang.String) (DalvikPushNotificationsService.java:93)

@jperedadnr
Copy link
Contributor Author

Right, in any case:
we should prevent the NPE (by checking that the file exists before calling Json.createReader(), and also prevent the JNI error by not passing an empty configuration to Firebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants