Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.addAnnotationIcon(java.lang.String, int, int, float, byte[])' on a null object reference and Error occurred trying to report a new Location #10563

Closed
hw118118 opened this issue Nov 27, 2017 · 4 comments
Labels
Android Mapbox Maps SDK for Android crash needs information

Comments

@hw118118
Copy link

hw118118 commented Nov 27, 2017

Platform: Android
Mapbox SDK version: 5.2.0

When I click a button, the map will load in a fragment. However, when click the button several times ,there is a error occured:

11-27 15:11:02.430 1821-1821/com.example.hgis.tdmapbox2 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: com.example.hgis.tdmapbox2, PID: 1821
                                                                          java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.addAnnotationIcon(java.lang.String, int, int, float, byte[])' on a null object reference
                                                                              at com.mapbox.mapboxsdk.maps.IconManager.loadIcon(IconManager.java:115)
                                                                              at com.mapbox.mapboxsdk.maps.IconManager.<init>(IconManager.java:37)
                                                                              at com.mapbox.mapboxsdk.maps.MapView.initialiseMap(MapView.java:174)
                                                                              at com.mapbox.mapboxsdk.maps.MapView.access$800(MapView.java:70)
                                                                              at com.mapbox.mapboxsdk.maps.MapView$5$1.run(MapView.java:304)
                                                                              at android.os.Handler.handleCallback(Handler.java:761)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                              at android.os.Looper.loop(Looper.java:156)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6523)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
11-27 15:11:02.438 1233-5868/? E/ReportTools: This is not beta user build
11-27 15:11:02.686 1977-1977/com.example.hgis.tdmapbox2:lost E/FusedLocationProviderServiceDelegate: Error occurred trying to report a new Location
                                                                                                     android.os.DeadObjectException
                                                                                                         at android.os.BinderProxy.transactNative(Native Method)
                                                                                                         at android.os.BinderProxy.transact(Binder.java:617)
                                                                                                         at com.mapzen.android.lost.internal.IFusedLocationProviderCallback$Stub$Proxy.onLocationChanged(IFusedLocationProviderCallback.java:129)
                                                                                                         at com.mapzen.android.lost.internal.FusedLocationProviderServiceDelegate.reportLocation(FusedLocationProviderServiceDelegate.java:95)
                                                                                                         at com.mapzen.android.lost.internal.FusionEngine.onLocationChanged(FusionEngine.java:196)
                                                                                                         at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:317)
                                                                                                         at android.location.LocationManager$ListenerTransport.-wrap0(LocationManager.java)
                                                                                                         at android.location.LocationManager$ListenerTransport$2.handleMessage(LocationManager.java:249)
                                                                                                         at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                                                         at android.os.Looper.loop(Looper.java:156)
                                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6523)
                                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
                                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
@Guardiola31337 Guardiola31337 added Android Mapbox Maps SDK for Android crash labels Nov 27, 2017
@hw118118
Copy link
Author

private void initialiseMap() {
    Context context = getContext();
    addOnMapChangedListener(mapCallback);

    // callback for focal point invalidation
    final FocalPointInvalidator focalPointInvalidator = new FocalPointInvalidator();
    focalPointInvalidator.addListener(createFocalPointChangeListener());

    // callback for registering touch listeners
    RegisterTouchListener registerTouchListener = new RegisterTouchListener();

    // callback for zooming in the camera
    CameraZoomInvalidator zoomInvalidator = new CameraZoomInvalidator();

    // callback for camera change events
    final CameraChangeDispatcher cameraChangeDispatcher = new CameraChangeDispatcher();

    // setup components for MapboxMap creation
    Projection proj = new Projection(nativeMapView);
    UiSettings uiSettings = new UiSettings(proj, focalPointInvalidator, compassView, attrView, logoView);
    TrackingSettings trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointInvalidator,
      zoomInvalidator);
    MyLocationViewSettings myLocationViewSettings = new MyLocationViewSettings(myLocationView, proj,
      focalPointInvalidator);
    LongSparseArray<Annotation> annotationsArray = new LongSparseArray<>();
    MarkerViewManager markerViewManager = new MarkerViewManager((ViewGroup) findViewById(R.id.markerViewContainer));
    IconManager iconManager = new IconManager(nativeMapView);
    Annotations annotations = new AnnotationContainer(nativeMapView, annotationsArray);

when I break, I find nativeMapView object is null. Why and what I shuld solve with it ???

@tobrun
Copy link
Member

tobrun commented Nov 29, 2017

@hw118118 could you add the code from When I click a button, the map will load in a fragment. Without that information it will be hard to reproduce the same scenario. Thank you.

@sictiru
Copy link

sictiru commented Dec 5, 2017

Maybe it's related but I'm using MapBox with its SupportMapManager within a viewPager and I get NPE on nativeMapView.destroy() ( @mapView.onDestroy() ) if I switch between the fragments in the viewPager.
Crash happening after updating from 5.1.5 to 5.2.0

@tobrun
Copy link
Member

tobrun commented Dec 6, 2017

@sictiru not related, fixed with #10589. Planning to ship that in a 5.2.1 patch release today.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android crash needs information
Projects
None yet
Development

No branches or pull requests

4 participants