Skip to content

PlatformException(STYLE IS NULL, The style is null. Has onStyleLoaded() already been invoked?, null) #384

Closed

Description

@hussenIbrahim

getting this error in released app Which causes symbols not to appear
on android real device
Flutter 1.21.0-7.0.pre • channel dev
package version 0.7.0

Non-fatal Exception: java.lang.Exception
PlatformException(STYLE IS NULL, The style is null. Has onStyleLoaded() already been invoked?, null)

this is my code

` MapboxMap(

      onStyleLoadedCallback: _onStyleLoadedCallback,
      trackCameraPosition: true,
      myLocationTrackingMode: MyLocationTrackingMode.Tracking,
      zoomGesturesEnabled: true,
      compassEnabled: false,
      myLocationEnabled: true,
      styleString: changeThemeNotifer.isDark()
          ? "assets/map_dark_style.json"
          : "assets/map_light_style.json",
      onMapCreated: _onMapCreated,
      initialCameraPosition: const CameraPosition(
          target: LatLng(0.0,0.0), zoom: 5),
    ),`

Activity

  1. m0nac0 commented on Aug 16, 2020

    @m0nac0
    Collaborator

    @hussenIbrahim Does this error occur when you add images? If yes, when do you add the images?

  2. hussenIbrahim commented on Aug 16, 2020

    @hussenIbrahim
    Author

    @hussenIbrahim Does this error occur when you add images? If yes, when do you add the images?

    i don't know where or when it occurs and this error not every time thrown
    i get the error from firebase Crashlytics
    ` void _onMapCreated(MapboxMapController controller) {
    print("map created");
    mapController = controller;
    addImageFromAsset();
    mapController.onSymbolTapped.add((argument) {
    _onSymbolTapped(argument);
    print(mapController.symbols.length);
    });
    }

    Future addImageFromAsset() async {
    ByteData bytes = await rootBundle.load("assets/icon.png");
    Uint8List list = bytes.buffer.asUint8List();
    mapController.addImage("icon", list);

    }`

  3. hussenIbrahim commented on Aug 16, 2020

    @hussenIbrahim
    Author

    getting this error in profile mode

    I/flutter ( 7556): RangeError (index): Invalid value: Only valid value is 0: 1 E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): Failed to handle method call E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:740) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.os.MessageQueue.next(MessageQueue.java:323) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.os.Looper.loop(Looper.java:136) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.app.ActivityThread.main(ActivityThread.java:6776) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) E/DartMessenger( 7556): Uncaught exception in binary message listener E/DartMessenger( 7556): java.lang.IllegalStateException: Reply already submitted E/DartMessenger( 7556): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:139) E/DartMessenger( 7556): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:246) E/DartMessenger( 7556): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/DartMessenger( 7556): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631) E/DartMessenger( 7556): at android.os.MessageQueue.nativePollOnce(Native Method) E/DartMessenger( 7556): at android.os.MessageQueue.next(MessageQueue.java:323) E/DartMessenger( 7556): at android.os.Looper.loop(Looper.java:136) E/DartMessenger( 7556): at android.app.ActivityThread.main(ActivityThread.java:6776) E/DartMessenger( 7556): at java.lang.reflect.Method.invoke(Native Method) E/DartMessenger( 7556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) E/DartMessenger( 7556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) I/flutter ( 7556): Error caught by Crashlytics plugin <recordError>: I/flutter ( 7556): RangeError (index): Invalid value: Only valid value is 0: 1 E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): Failed to handle method call E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:740) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.os.MessageQueue.next(MessageQueue.java:323) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.os.Looper.loop(Looper.java:136) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at android.app.ActivityThread.main(ActivityThread.java:6776) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) E/MethodChannel#plugins.flutter.io/mapbox_maps_0( 7556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) E/DartMessenger( 7556): Uncaught exception in binary message listener E/DartMessenger( 7556): java.lang.IllegalStateException: Reply already submitted E/DartMessenger( 7556): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:139) E/DartMessenger( 7556): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:246) E/DartMessenger( 7556): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85) E/DartMessenger( 7556): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631) E/DartMessenger( 7556): at android.os.MessageQueue.nativePollOnce(Native Method) E/DartMessenger( 7556): at android.os.MessageQueue.next(MessageQueue.java:323) E/DartMessenger( 7556): at android.os.Looper.loop(Looper.java:136) E/DartMessenger( 7556): at android.app.ActivityThread.main(ActivityThread.java:6776) E/DartMessenger( 7556): at java.lang.reflect.Method.invoke(Native Method) E/DartMessenger( 7556): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) E/DartMessenger( 7556): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

  4. m0nac0 commented on Aug 17, 2020

    @m0nac0
    Collaborator

    @hussenIbrahim As noted in the documentation, please only call addImage() after onStyleLoaded callback has been invoked. Otherwise you might get this error, as images are added to a style, which isn't possible when the style hasn't been completely loaded, yet.

  5. hussenIbrahim commented on Aug 17, 2020

    @hussenIbrahim
    Author

    the error is solved for release and profile mode
    but in debug mode on onStyleLoaded callback its invoked once when app is installed else it is not invoked until uninstall the app or clear the app cache
    thanks @m0nac0

  6. m0nac0 commented on Aug 17, 2020

    @m0nac0
    Collaborator

    @hussenIbrahim Interesting, that sounds similar to what has been described in #347 (but only for iOS so far). Unfortunately I haven't been able to reproduce that, yet, but I'll look out for it if you also experience this on Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions