Android crash on 'boolean com.mapbox.mapboxsdk.maps.Style.isFullyLoaded()' on a null object reference,


Hi I am trying MapBox for navigation and getting crash like this

2019-01-20 19:00:16.331 32005-32005/com.example.mapboxtest E/Mbgl-MapChangeReceiver: Exception in onDidFinishLoadingStyle
android.content.res.Resources$NotFoundException: Resource ID #0xffffffff
    at android.content.res.ResourcesImpl.getValueForDensity(
    at android.content.res.Resources.getDrawableForDensity(
    at android.content.res.Resources.getDrawable(
    at android.content.Context.getDrawable(
    at com.mapbox.mapboxsdk.location.Utils.getDrawable(
    at com.mapbox.mapboxsdk.location.LayerBitmapProvider.generateBitmap(
    at com.mapbox.mapboxsdk.location.LocationLayerController.styleForeground(
    at com.mapbox.mapboxsdk.location.LocationLayerController.applyStyle(
    at com.mapbox.mapboxsdk.location.LocationLayerController.initializeComponents(
    at com.mapbox.mapboxsdk.location.LocationLayerController.<init>(
    at com.mapbox.mapboxsdk.location.LocationComponent.initialize(
    at com.mapbox.mapboxsdk.location.LocationComponent.activateLocationComponent(
    at com.example.mapboxtest.MainActivity$1.onStyleLoaded(
    at com.mapbox.mapboxsdk.maps.MapboxMap.notifyStyleLoaded(
    at com.mapbox.mapboxsdk.maps.MapboxMap.onFinishLoadingStyle(
    at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onDidFinishLoadingStyle(
    at com.mapbox.mapboxsdk.maps.MapChangeReceiver.onDidFinishLoadingStyle(
    at com.mapbox.mapboxsdk.maps.NativeMapView.onDidFinishLoadingStyle(
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)

These are the dependencies that I am using now

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.0.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.27.0'

This is where I get the crash

    public void onMapReady(@NonNull MapboxMap mapboxMap) {
        mMapboxMap = mapboxMap;
        mapboxMap.setStyle(new Style.Builder().fromUrl(getString(R.string.navigation_guidance)), new Style.OnStyleLoaded() {
            public void onStyleLoaded(@NonNull Style style) {
//                enableLocationComponent();
                if (style.isFullyLoaded()) {
                    navigationMap = new NavigationMapboxMap(mapView, mMapboxMap);
//                // For Location updates
//                initializeLocationEngine();
//                // For navigation logic / processing
//        initializeNavigation(mMapboxMap);

This line is causing the issue

navigationMap = new NavigationMapboxMap(mapView, mMapboxMap);

I checked this link

and found something like this

In order to avoid java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.mapbox.mapboxsdk.maps.Style.isFullyLoaded()' on a null object reference, the provided style parameter in the LocationComponent#activate method has to be @NonNull and fully loaded. The best way is to pass the style provided in the OnStyleLoaded callback.

But still no luck.

asked on Stack Overflow Jan 20, 2019 by shine_joseph

2 Answers


I was facing the same issue and tried all the solutions. I updated to latest mapbox sdk 8.4.0, and followed the ComponentNavigationActivity#onMapReady, but still no luck.

Then I found that we need to put:

<item name="navigationViewLocationLayerStyle">@style/NavigationLocationLayerStyle</item>

inside the custom instructions view style and apply it inside onCreate() like this:


This solved the issue. I hope it helps!

answered on Stack Overflow Oct 3, 2019 by Pawan Parihar • edited Oct 3, 2019 by Pawan Parihar
0 is moving to fix this by providing a default if a valid style is not found. In the meantime, you can add this snippet to your style.xml to fix:

<item name="navigationViewLocationLayerStyle">@style/NavigationLocationLayerStyle</item>

answered on Stack Overflow Jan 23, 2019 by Dan Nesfeder

User contributions licensed under CC BY-SA 3.0