Support Topics Documentation Slack YouTube Blog

Device Registration for Push Notifications not working on Android 9

Backendless_SDK: 0.3.1

Flutter in Android Studio (version 3.5)

• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 40.1.2
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

Application ID

859418E3-AA83-93D2-FF8E-C0009E704C00

Expected Behavior

I’m hoping the Device registers correctly for the Backendless Messaging Service.

The error log mentions Firebase, I think its because of following this guide, which suggests editting AndroidManifest.xml:

1. Run should print Device has been registered

Actual Behavior

W/apulta.parki_v(31476): Accessing hidden method Landroid/app/ActivityThread;->currentApplication()Landroid/app/Application; (light greylist, reflection)
E/MethodChannel#backendless/messaging(31476): Failed to handle method call
E/MethodChannel#backendless/messaging(31476): java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process app.catapulta.parki_v5. Make sure to call FirebaseApp.initializeApp(Context) first.
E/MethodChannel#backendless/messaging(31476): at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@19.0.0:180)
E/MethodChannel#backendless/messaging(31476): at com.google.firebase.iid.FirebaseInstanceId.getInstance(com.google.firebase:firebase-iid@@20.0.0:1)
E/MethodChannel#backendless/messaging(31476): at com.google.firebase.messaging.FirebaseMessaging.getInstance(com.google.firebase:firebase-messaging@@20.0.0:2)
E/MethodChannel#backendless/messaging(31476): at com.backendless.push.FCMRegistration.registerDevice(FCMRegistration.java:39)
E/MethodChannel#backendless/messaging(31476): at com.backendless.Messaging.registerDevice(Messaging.java:200)
E/MethodChannel#backendless/messaging(31476): at com.backendless.Messaging.registerDevice(Messaging.java:179)
E/MethodChannel#backendless/messaging(31476): at com.backendless.backendless_sdk.call_handlers.MessagingCallHandler.registerDevice(MessagingCallHandler.java:198)
E/MethodChannel#backendless/messaging(31476): at com.backendless.backendless_sdk.call_handlers.MessagingCallHandler.onMethodCall(MessagingCallHandler.java:67)
E/MethodChannel#backendless/messaging(31476): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#backendless/messaging(31476): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#backendless/messaging(31476): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#backendless/messaging(31476): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#backendless/messaging(31476): at android.os.MessageQueue.next(MessageQueue.java:386)
E/MethodChannel#backendless/messaging(31476): at android.os.Looper.loop(Looper.java:175)
E/MethodChannel#backendless/messaging(31476): at android.app.ActivityThread.main(ActivityThread.java:7625)
E/MethodChannel#backendless/messaging(31476): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#backendless/messaging(31476): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
E/MethodChannel#backendless/messaging(31476): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
E/ (31476): [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
E/flutter (31476): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Default FirebaseApp is not initialized in this process app.catapulta.parki_v5. Make sure to call FirebaseApp.initializeApp(Context) first., null)
E/flutter (31476): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (31476): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (31476):
E/flutter (31476): #2 BackendlessMessaging.registerDevice (package:backendless_sdk/src/modules/messaging/messaging.dart:62:30)
E/flutter (31476): #3 _RegistroState.initState (package:parki_v5/viewcontrollers/registro/registro_page.dart:63:27)
E/flutter (31476): #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4068:58)
E/flutter (31476): #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3919:5)

Reproducible Test Case

The Flutter Push Notifications Setup

Hello @Samuel_Franco

I’ve created an internal ticket to investigate the issue, ticket’s number is BKNDLSS-19789

Regards, Vlad

Hi @Samuel_Franco

Is it working for another Android versions for you?

Best Regards,
Maksym

Also, @Samuel_Franco, did you add Firebase dependencies to your Android build.gradle file

implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'

as described here:
https://backendless.com/docs/android/push_push_notification_setup_androi.html