Skip to content

Crash when using in combination with firebase_messaging #45

@Niek

Description

@Niek

When using firebase_messaging, you need to to add your own Application class that implements PluginRegistrantCallback. However, this causes WiFiFlutter to crash with the following trace:

E/MethodChannel#plugins.flutter.io/firebase_messaging(10125): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at com.alternadom.wifiiot.WifiIotPlugin.<init>(WifiIotPlugin.java:65)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at com.alternadom.wifiiot.WifiIotPlugin.registerWith(WifiIotPlugin.java:76)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:26)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at com.mypack.myapp.Application.registerWith(Application.java:18)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.startBackgroundIsolate(FlutterFirebaseMessagingService.java:164)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin.onMethodCall(FirebaseMessagingPlugin.java:134)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#plugins.flutter.io/firebase_messaging(10125):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

It's coming from this call: https://github.com/alternadom/WiFiFlutter/blob/a8bb37f87425e45d2947e6c7c4e8b9416c886364/android/src/main/java/com/alternadom/wifiiot/WifiIotPlugin.java#L65

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions