I'm trying to integrate the Mapbox maps plugin into my Flutter app, but I'm encountering an IllegalStateException when the map is displayed. Here's the error message:
Shutting down VM
E/AndroidRuntime(17194): FATAL EXCEPTION: main
E/AndroidRuntime(17194): Process: com.example.verygoodcore.navigation, PID: 17194
E/AndroidRuntime(17194): java.lang.IllegalStateException: Please ensure that the hosting activity/fragment is a valid LifecycleOwner
E/AndroidRuntime(17194): at com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner.doOnAttached(ViewLifecycleOwner.kt:68)
E/AndroidRuntime(17194): at com.mapbox.maps.plugin.lifecycle.ViewLifecycleOwner.<init>(ViewLifecycleOwner.kt:58)
E/AndroidRuntime(17194): at com.mapbox.maps.plugin.lifecycle.MapboxLifecyclePluginImpl.registerLifecycleObserver(MapboxLifecyclePluginImpl.kt:30)
E/AndroidRuntime(17194): at com.mapbox.maps.plugin.MapPluginRegistry.onAttachedToWindow(MapPluginRegistry.kt:173)
E/AndroidRuntime(17194): at com.mapbox.maps.MapController.onAttachedToWindow$sdk_publicRelease(MapController.kt:346)
E/AndroidRuntime(17194): at com.mapbox.maps.MapView.onAttachedToWindow(MapView.kt:129)
E/AndroidRuntime(17194): at android.view.View.dispatchAttachedToWindow(View.java:21976)
E/AndroidRuntime(17194): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4293)
5
E/AndroidRuntime(17194): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:4302)
E/AndroidRuntime(17194): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3443)
E/AndroidRuntime(17194): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2893)
E/AndroidRuntime(17194): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10445)
E/AndroidRuntime(17194): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1108)
E/AndroidRuntime(17194): at android.view.Choreographer.doCallbacks(Choreographer.java:866)
E/AndroidRuntime(17194): at android.view.Choreographer.doFrame(Choreographer.java:797)
E/AndroidRuntime(17194): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092)
E/AndroidRuntime(17194): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(17194): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17194): at android.os.Looper.loopOnce(Looper.java:226)
E/AndroidRuntime(17194): at android.os.Looper.loop(Looper.java:313)
E/AndroidRuntime(17194): at android.app.ActivityThread.main(ActivityThread.java:8663)
E/AndroidRuntime(17194): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17194): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
E/AndroidRuntime(17194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
I/Process (17194): Sending signal. PID: 17194 SIG: 9
I've made sure that the activity hosting the map view implements the LifecycleOwner interface, but the error still persists. I believe the issue is with the Mapbox maps plugin itself.
Steps to reproduce:
Create a new Flutter app.
Add the Mapbox maps plugin to the pubspec.yaml file.
Display the map view.
Expected result:
The Mapbox map should be displayed without any errors.
Actual result:
The app crashes with the following the highlighted error message.
czar@Ayotomides-MacBook-Pro navigation % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.7, on macOS 13.0 22A380 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.77.3)
[✓] Connected device (4 available)
[✓] HTTP Host Availability
• No issues found!
I'm trying to integrate the Mapbox maps plugin into my Flutter app, but I'm encountering an IllegalStateException when the map is displayed. Here's the error message:
I've made sure that the activity hosting the map view implements the LifecycleOwner interface, but the error still persists. I believe the issue is with the Mapbox maps plugin itself.
Steps to reproduce:
The Mapbox map should be displayed without any errors.
Actual result: The app crashes with the following the highlighted error message.
Environment:
Flutter version: 3.7.7 Mapbox maps plugin version: 0.4.2 Android device running API level 31
Flutter Doctor result: