rmawatson/flutter_isolate

java.lang.NullPointerException: println needs a message

Closed this issue · 5 comments

I get the following error any time i try to to spawn a new FlutterIsolate

E/MethodChannel#com.rmawatson.flutterisolate/control(10197): Failed to handle method call
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): java.lang.NullPointerException: println needs a message
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at android.util.Log.println_native(Native Method)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at android.util.Log.e(Log.java:232)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at com.rmawatson.flutterisolate.FlutterIsolatePlugin.startNextIsolate(FlutterIsolatePlugin.java:91)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at com.rmawatson.flutterisolate.FlutterIsolatePlugin.onMethodCall(FlutterIsolatePlugin.java:128)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at android.os.MessageQueue.next(MessageQueue.java:328)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at android.os.Looper.loop(Looper.java:164)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at android.app.ActivityThread.main(ActivityThread.java:5683)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E/MethodChannel#com.rmawatson.flutterisolate/control(10197): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
E/flutter (10197): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (10197): PlatformException(error, println needs a message, null)
E/flutter (10197): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (10197): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter (10197):
E/flutter (10197): #2 FlutterIsolate.spawn (package:flutter_isolate/flutter_isolate.dart:44:14)
E/flutter (10197):
E/flutter (10197): #3 start (package:scoodent/contollers/chats/chat_notif_controller.dart:78:34)
E/flutter (10197):

This is my code

void main(String main) async{
// ChatNotifController();
}

Isolate isolate;

void start() async {
isolate = await FlutterIsolate.spawn(main, "main");
}

i commented out my code to see if it was an issue from my part but as you can see error still persist

thanks in advance

Try and pull the the latest changes from this repo.

The problem you are seeing is there is an exception thrown here and getmessage() on the exception is null. I have since updated to give a more informative message. But if you are seeing this, one of the plugins you are trying to register is probably failing. See the message I added here for why this probably is happening.

You can try only registering plugins you need to use in the isolate using setCustomRegistrant (basically copy the code for GeneratedPluginRegistrant, rename it as something else like IsolatePluginRegistrant, remove the lines to all plugins you are not using and register with FlutterIsolatePlugin.setCustomRegistrant(IsolatePluginRegistrant.class)

await FlutterIsolate.spawn(main, "main"); this does not return an Isolate, but a FlutterIsolate.
also, you are spawning with main as your entry point? which is usually the entry point for the main isolate launched by flutter.. ? not sure that's a great idea.

For the part where you spoke of a registered plugin failing I intentionally left the main (which I have change the name but) method to see the result but the error still persist.

I have change the main method name and string passed to different names.

Also I'm not using any plugin I made my self I'm only using the flutter_notification and cloud_firestore package .

I just tried with this "flutter_local_notification" package, I assume that is the one you mean? appears to work ok for me. You can try updating to the latest from flutter packages.

Did you try using cloud_firestore?

Would be nice to know the version of flutter_notification you are using and also your sample implementation which works fine

I'm using flutter_local_notifications .. I can't find another package, 0.5.2 apparently. I've not tried cloud_firestore. I pushed an update to flutter packages, did you try that?