Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android/Example: offline region manager broken #543

Closed
felix-ht opened this issue Feb 15, 2021 · 1 comment · Fixed by #544
Closed

Android/Example: offline region manager broken #543

felix-ht opened this issue Feb 15, 2021 · 1 comment · Fixed by #544

Comments

@felix-ht
Copy link
Collaborator

felix-ht commented Feb 15, 2021

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();

@felix-ht felix-ht changed the title Android/Example: offline region manager getListOfRegions fails Android/Example: offline region manager broken Feb 15, 2021
@willylambert
Copy link

We also have the same issue on Android with the example app, tested with flutter 1.22.4 and 1.22.6.
iOS version is ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants