mapbox / mapbox-maps-flutter

Interactive, thoroughly customizable maps for Flutter powered by Mapbox Maps SDK
https://www.mapbox.com/mobile-maps-sdk
Other
289 stars 119 forks source link

PlatformException(error, java.lang.IllegalStateException: Please ensure that the hosting activity/fragment is a valid LifecycleOwner #60

Closed alexeileyvamora closed 7 months ago

alexeileyvamora commented 1 year ago

E/flutter ( 6746): at com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner.doOnAttached(ViewLifecycleOwner.kt:68) E/flutter ( 6746): at com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner.(ViewLifecycleOwner.kt:58) E/flutter ( 6746): at com.mapbox.maps.plugin.lifecycle.MapboxLifecyclePluginImpl.registerLifecycleObserver(MapboxLifecyclePluginImpl.kt:30) E/flutter ( 6746): at com.mapbox.maps.plugin.MapPluginRegistry.onAttachedToWindow(MapPluginRegistry.kt:173) E/flutter ( 6746): at com.mapbox.maps.MapController.onAttachedToWindow$sdk_release(MapController.kt:333) E/flutter ( 6746): at com.mapbox.maps.MapView.onAttachedToWindow(MapView.kt:115) E/flutter ( 6746): at android.view.View.dispatchAttachedToWindow(View.java:19702) E/flutter ( 6746): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3518) E/flutter ( 6746): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3525) E/flutter ( 6746): at android.view.ViewGroup.addViewInner(ViewGroup.java:5255) E/flutter ( 6746): at android.view.ViewGroup.addView(ViewGroup.java:5035) E/flutter ( 6746): at android.view.ViewGroup.addView(ViewGroup.java:4972) E/flutter ( 6746): at android.view.ViewGroup.addView(ViewGroup.java:4945) E/flutter ( 6746): at io.flutter.plugin.platform.PlatformViewsController$1.configureForTextureLayerComposition(PlatformViewsController.java:647) E/flutter ( 6746): at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:225) E/flutter ( 6746): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:128) E/flutter ( 6746): at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55) E/flutter ( 6746): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/flutter ( 6746): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter ( 6746): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/flutter ( 6746): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter ( 6746): at android.os.Handler.handleCallback(Handler.java:914) E/flutter ( 6746): at android.os.Handler.dispatchMessage(Handler.java:100) E/flutter ( 6746): at android.os.Looper.loop(Looper.java:225) E/flutter ( 6746): at android.app.ActivityThread.main(ActivityThread.java:7563) E/flutter ( 6746): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 6746): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) E/flutter ( 6746): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)

yunikkk commented 1 year ago

Hey @alexeileyvamora , any details about your setup? Have you tried the sample application, does it work on your device?

alexeileyvamora commented 1 year ago

@yunikkk Thanks for answering me. I am using the flutter_mapbox_navigation package I have fixed it at the moment with

configurations { all*.exclude group: 'com.mapbox.plugin', module: 'maps-lifecycle' }

alexeileyvamora commented 1 year ago

W/Mapbox (12702): [TelemetryUtils]: java.lang.SecurityException: getDataNetworkTypeForSubscriber I/Mapbox (12702): [maps-android\MapController]: Add MAPBOX_LIFECYCLE_PLUGIN_ID plugin dependency to the classpath take automatically load the plugin implementation.

evil159 commented 7 months ago

Hi all, this issue should be fixed in https://github.com/mapbox/mapbox-maps-flutter/pull/478, feel free to reopen this ticket if you have any feedback!