Closed Luvti closed 3 years ago
Hey @Luvti , Thanks for reaching out!
I've investigated a bit, and it seems because "_firebaseMessagingBackgroundHandler' runs in its own isolate outside your applications context" this is probably the reason this error appears. Please check this section on the firebase flutter docs: https://firebase.flutter.dev/docs/messaging/usage/#background-messages
What is your use case? Maybe we can find another way to tackle this.
I got the same issue when the application was in the background and then flutter activity was destroyed. Turn on 'Don't keep activities' in 'Developer options' can reproduce this.
E/MethodChannel#af-api: Failed to handle method call
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
at com.appsflyer.AppsFlyerLibCore.start(:921)
at com.appsflyer.AppsFlyerLibCore.start(:902)
at com.appsflyer.AppsFlyerLibCore.start(:897)
at com.appsflyer.appsflyersdk.AppsflyerSdkPlugin.initSdk(AppsflyerSdkPlugin.java:586)
at com.appsflyer.appsflyersdk.AppsflyerSdkPlugin.onMethodCall(AppsflyerSdkPlugin.java:128)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:335)
at android.os.Looper.loop(Looper.java:183)
at android.app.ActivityThread.main(ActivityThread.java:7664)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Hey, has anyone found a solution for this?
Describe the bug Init AppsFlyer in a background process on Android device causes a NullPointerException
To Reproduce Steps to reproduce the behavior:
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
Expected behavior No error.