josephcrowell / flutter_mapbox_turn_by_turn

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

Blank(black) screen on Android #4

Closed aleonnet closed 10 months ago

aleonnet commented 10 months ago

Hi @josephcrowell! Cannot see any map on Android.

I got an initialization error << E/MethodChannel#flutter_mapbox_turn_by_turn/method(23853): kotlin.UninitializedPropertyAccessException: lateinit property context has not been initialized

And changed the following on FlutterMapboxTurnByTurnPlugin.kt:

private fun isPermissionGranted(): Boolean { if (!::context.isInitialized) { Log.e("FlutterMapboxTurnByTurnPlugin", "Context has not been initialized yet.") return false }

val coarseResult: Int = ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) val fineResult: Int = ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)

return coarseResult == PackageManager.PERMISSION_GRANTED && fineResult == PackageManager.PERMISSION_GRANTED }

josephcrowell commented 10 months ago

Look at the Manifest section here: https://docs.mapbox.com/android/navigation/guides/get-started/install/

I haven't added the instructions/documentation for adding permissions etc but you haven't added the ACCESS_COARSE_LOCATION and ACCESS_FILE_LOCATION permissions to your manifest.

It also looks like you haven't initialized the map object before trying to use it. Have a look at the example in the examples folder.