-
Notifications
You must be signed in to change notification settings - Fork 543
Closed
Description
For me none of the global function for managing offline regions work. The same issue also happens in the with the example app from the current master branch.
They fail with:
/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): Failed to handle method call
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): java.lang.NullPointerException: Attempt to invoke interface method 'android.content.Context io.flutter.plugin.common.PluginRegistry$Registrar.context()' on a null object reference
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at com.mapbox.mapboxgl.GlobalMethodHandler.onMethodCall(GlobalMethodHandler.java:61)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:693)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at android.os.Looper.loop(Looper.java:183)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#plugins.flutter.io/mapbox_gl( 9206): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I added some debug code to onMethodCall in the GlobalMethodHandler
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
Log.d("offlineTEST", "onMethodCall -> " + methodCall.method);
Log.d("offlineTEST", "onMethodCall registrar -> " + registrar);
Log.d("offlineTEST", "onMethodCall flutterAssets -> " + flutterAssets);
Log.d("offlineTEST", "onMethodCall context -> " + context);
this leads to the following output:
D/offlineTEST( 9206): onMethodCall -> getListOfRegions
D/offlineTEST( 9206): onMethodCall registrar -> null
D/offlineTEST( 9206): onMethodCall flutterAssets -> io.flutter.embedding.engine.FlutterEngineConnectionRegistry$DefaultFlutterAssets@9c135c7
D/offlineTEST( 9206): onMethodCall context -> androidx.multidex.MultiDexApplication@f70fc9
This might be related to #488 as the new plugin api does not provide a regsistar to the method handler:
new
methodChannel.setMethodCallHandler(
new GlobalMethodHandler(
binding.getApplicationContext(),
binding.getFlutterAssets()
)
);
old
methodChannel.setMethodCallHandler(new GlobalMethodHandler(registrar));
Trying to get the context from the registrar that is null, is the cause for the error in final Context context = registrar.context();
Metadata
Metadata
Assignees
Labels
No labels