eopeter / flutter_mapbox_navigation

Turn By Turn Navigation for Your Flutter Application
Apache License 2.0
217 stars 184 forks source link

java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Boolean #289

Closed mbaka-bilal closed 1 year ago

mbaka-bilal commented 1 year ago

i followed all the setup instructions for android from the pub.dev page but when try to run the code it throws error:

//Code from pub.dev
final cityhall = WayPoint(name: "City Hall", latitude: 42.886448, longitude: -78.878372);
final downtown = WayPoint(name: "Downtown Buffalo", latitude: 42.8866177, longitude: -78.8814924);

var wayPoints = <WayPoint>[];
wayPoints.add(cityhall);
wayPoints.add(downtown);

This is the log

_E/MethodChannel#flutter_mapbox_navigation(10680): Failed to handle method call
E/MethodChannel#flutter_mapbox_navigation(10680): java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Boolean
E/MethodChannel#flutter_mapbox_navigation(10680):   at com.eopeter.fluttermapboxnavigation.FlutterMapboxNavigationPlugin.checkPermissionAndBeginNavigation(FlutterMapboxNavigationPlugin.kt:177)
E/MethodChannel#flutter_mapbox_navigation(10680):   at com.eopeter.fluttermapboxnavigation.FlutterMapboxNavigationPlugin.onMethodCall(FlutterMapboxNavigationPlugin.kt:95)
E/MethodChannel#flutter_mapbox_navigation(10680):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/MethodChannel#flutter_mapbox_navigation(10680):   at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#flutter_mapbox_navigation(10680):   at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/MethodChannel#flutter_mapbox_navigation(10680):   at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#flutter_mapbox_navigation(10680):   at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#flutter_mapbox_navigation(10680):   at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#flutter_mapbox_navigation(10680):   at android.os.Looper.loop(Looper.java:223)
E/MethodChannel#flutter_mapbox_navigation(10680):   at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#flutter_mapbox_navigation(10680):   at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_mapbox_navigation(10680):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#flutter_mapbox_navigation(10680):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (10680): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, null cannot be cast to non-null type kotlin.Boolean, null, java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Boolean
E/flutter (10680):  at com.eopeter.fluttermapboxnavigation.FlutterMapboxNavigationPlugin.checkPermissionAndBeginNavigation(FlutterMapboxNavigationPlugin.kt:177)
E/flutter (10680):  at com.eopeter.fluttermapboxnavigation.FlutterMapboxNavigationPlugin.onMethodCall(FlutterMapboxNavigationPlugin.kt:95)
E/flutter (10680):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/flutter (10680):  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter (10680):  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/flutter (10680):  at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter (10680):  at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (10680):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (10680):  at android.os.Looper.loop(Looper.java:223)
E/flutter (10680):  at android.app.ActivityThread.main(ActivityThread.java:7656)
E/flutter (10680):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (10680):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (10680):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (10680): )
E/flutter (10680): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter (10680): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter (10680): <asynchronous suspension>
E/flutter (10680): #2      MethodChannelFlutterMapboxNavigation.startNavigation (package:flutter_mapbox_navigation/src/flutter_mapbox_navigation_method_channel.dart:77:20)
E/flutter (10680): <asynchronous suspension>
E/flutter (10680): #3      _EnrouteScreenState.startNavigation (package:maps_play/screens/map/components/en_route.dart:116:5)
E/flutter (10680): <asynchronous suspension>
E/flutter (10680):_ 
AlanGood113 commented 1 year ago

The isSilent property on the Waypoints must be there. For example:
WayPoint( name: "Destination", latitude: 13.159545, longitude: -61.224829, isSilent: false)

eopeter commented 1 year ago

This is resolved in v0.1.9