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

Crash with PendingJavaException when switching back to style that had geojson source/layer #8353

Closed
cammace opened this issue Mar 10, 2017 · 1 comment · Fixed by #8380
Closed
Assignees
Labels
Android Mapbox Maps SDK for Android bug

Comments

@cammace
Copy link
Contributor

cammace commented Mar 10, 2017

If I add a source and layer to a map style, switch to a different style, adding the same source and layer there, and then finally, switch back to the original style I started out with, I get a pending java exception and the application crashes.

ezgif com-video-to-gif

03-10 11:09:59.666 29188-29193/com.mapbox.mapboxsdk.testapp I/art: Do partial code cache collection, code=24KB, data=30KB
03-10 11:09:59.666 29188-29193/com.mapbox.mapboxsdk.testapp I/art: After code cache collection, code=21KB, data=28KB
03-10 11:09:59.666 29188-29193/com.mapbox.mapboxsdk.testapp I/art: Increasing code cache capacity to 128KB
03-10 11:09:59.675 29188-29188/com.mapbox.mapboxsdk.testapp W/art: Attempt to remove non-JNI local reference, dumping thread
03-10 11:09:59.676 29188-29188/com.mapbox.mapboxsdk.testapp A/libc: /Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type jni::PendingJavaException" failed
03-10 11:09:59.677 29188-29188/com.mapbox.mapboxsdk.testapp A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 29188 (pboxsdk.testapp)
                                                                    
                                                                    [ 03-10 11:09:59.677   559:  559 W/         ]
                                                                    debuggerd: handling request: pid=29188 uid=10261 gid=10261 tid=29188
03-10 11:09:59.757 29412-29412/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-10 11:09:59.758 29412-29412/? A/DEBUG: Build fingerprint: 'google/sailfish/sailfish:7.1.1/NOF26V/3636322:user/release-keys'
03-10 11:09:59.758 29412-29412/? A/DEBUG: Revision: '0'
03-10 11:09:59.758 29412-29412/? A/DEBUG: ABI: 'arm'
03-10 11:09:59.758 29412-29412/? A/DEBUG: pid: 29188, tid: 29188, name: pboxsdk.testapp  >>> com.mapbox.mapboxsdk.testapp <<<
03-10 11:09:59.758 29412-29412/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
03-10 11:09:59.760 29412-29412/? A/DEBUG: Abort message: '/Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type jni::PendingJavaException" failed'
03-10 11:09:59.760 29412-29412/? A/DEBUG:     r0 00000000  r1 00007204  r2 00000006  r3 00000008
03-10 11:09:59.760 29412-29412/? A/DEBUG:     r4 f3c9458c  r5 00000006  r6 f3c94534  r7 0000010c
03-10 11:09:59.760 29412-29412/? A/DEBUG:     r8 00000000  r9 e4983acc  sl 00000026  fp e4983a80
03-10 11:09:59.760 29412-29412/? A/DEBUG:     ip 0000000b  sp ffae6de8  lr f31cf5c7  pc f31d1e30  cpsr 600d0010
03-10 11:10:00.097 29412-29412/? A/DEBUG: backtrace:
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #00 pc 00049e30  /system/lib/libc.so (tgkill+12)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #01 pc 000475c3  /system/lib/libc.so (pthread_kill+34)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #02 pc 0001d635  /system/lib/libc.so (raise+10)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #03 pc 00019181  /system/lib/libc.so (__libc_android_abort+34)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #04 pc 00017048  /system/lib/libc.so (abort+4)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #05 pc 0001b633  /system/lib/libc.so (__libc_fatal+22)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #06 pc 0001937b  /system/lib/libc.so (__assert2+18)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #07 pc 005efc31  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #08 pc 005efd13  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #09 pc 005ee481  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #10 pc 005edf45  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so (__cxa_throw+96)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #11 pc 0005477f  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #12 pc 000cd439  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #13 pc 000b3805  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #14 pc 000b365f  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #15 pc 0012c86b  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #16 pc 00174841  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #17 pc 00128207  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #18 pc 0012e0a9  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #19 pc 0012ddf1  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #20 pc 0012dd3f  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #21 pc 00054dc1  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #22 pc 002270e1  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #23 pc 0022703b  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #24 pc 00226fcf  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #25 pc 00049b55  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #26 pc 00049c31  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #27 pc 000481c7  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #28 pc 00011e73  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+614)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #29 pc 00011b7f  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+26)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #30 pc 00093779  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvP8_jobjecti+22)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #31 pc 01bb091d  /system/framework/arm/boot-framework.oat (offset 0x158b000) (android.os.MessageQueue.nativePollOnce+96)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #32 pc 01bb1e31  /system/framework/arm/boot-framework.oat (offset 0x158b000) (android.os.MessageQueue.next+188)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #33 pc 01bad6a3  /system/framework/arm/boot-framework.oat (offset 0x158b000) (android.os.Looper.loop+366)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #34 pc 016113a7  /system/framework/arm/boot-framework.oat (offset 0x158b000) (android.app.ActivityThread.main+426)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #35 pc 000a9941  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #36 pc 00405d91  /system/lib/libart.so (art_quick_invoke_static_stub+228)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #37 pc 000b0c1b  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+178)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #38 pc 00316333  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+58)
03-10 11:10:00.097 29412-29412/? A/DEBUG:     #39 pc 003176a7  /system/lib/libart.so (_ZN3art12InvokeMethodERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectS4_S4_j+766)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #40 pc 002be5f1  /system/lib/libart.so (_ZN3artL13Method_invokeEP7_JNIEnvP8_jobjectS3_S3_+40)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #41 pc 005adbc9  /system/framework/arm/boot.oat (offset 0x51a000) (java.lang.reflect.Method.invoke+116)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #42 pc 020a0229  /system/framework/arm/boot-framework.oat (offset 0x158b000) (com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run+100)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #43 pc 020a10af  /system/framework/arm/boot-framework.oat (offset 0x158b000) (com.android.internal.os.ZygoteInit.main+1218)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #44 pc 000a9941  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #45 pc 00405d91  /system/lib/libart.so (art_quick_invoke_static_stub+228)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #46 pc 000b0c1b  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+178)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #47 pc 00316333  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+58)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #48 pc 00316143  /system/lib/libart.so (_ZN3art17InvokeWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDSt9__va_list+266)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #49 pc 00278b37  /system/lib/libart.so (_ZN3art3JNI21CallStaticVoidMethodVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+426)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #50 pc 00067d91  /system/lib/libandroid_runtime.so
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #51 pc 0006965f  /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcRKNS_6VectorINS_7String8EEEb+498)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #52 pc 00001945  /system/bin/app_process32
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #53 pc 00016c61  /system/lib/libc.so (__libc_init+48)
03-10 11:10:00.098 29412-29412/? A/DEBUG:     #54 pc 00001564  /system/bin/app_process32

and lastly, the code I am using to produce this issue:

package com.mapbox.mapboxsdk.testapp.activity.maplayout;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;

import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.services.commons.geojson.Feature;
import com.mapbox.services.commons.geojson.FeatureCollection;
import com.mapbox.services.commons.geojson.LineString;
import com.mapbox.services.commons.models.Position;

import java.util.ArrayList;
import java.util.List;

/**
 * Test activity showcasing a simple MapView without any MapboxMap interaction.
 */
public class SimpleMapActivity extends AppCompatActivity implements OnMapReadyCallback, MapboxMap.OnMapClickListener {

  private MapView mapView;
  private MapboxMap mapboxMap;
  List<Position> routeCoordinates;

  private boolean satellite;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map_simple);

    routeCoordinates = new ArrayList<>();
    routeCoordinates.add(Position.fromCoordinates(-118.39439114221236, 33.397676454651766));
    routeCoordinates.add(Position.fromCoordinates(-118.39421054012902, 33.39769799454838));
    routeCoordinates.add(Position.fromCoordinates(-118.39408583869053, 33.39761901490136));
    routeCoordinates.add(Position.fromCoordinates(-118.39388373635917, 33.397328225582285));
    routeCoordinates.add(Position.fromCoordinates(-118.39372033447427, 33.39728514560042));
    routeCoordinates.add(Position.fromCoordinates(-118.3930882271826, 33.39756875508861));
    routeCoordinates.add(Position.fromCoordinates(-118.3928216241072, 33.39759029501192));
    routeCoordinates.add(Position.fromCoordinates(-118.39227981785722, 33.397234885594564));
    routeCoordinates.add(Position.fromCoordinates(-118.392021814881, 33.397005125197666));
    routeCoordinates.add(Position.fromCoordinates(-118.39090810203379, 33.396814854409186));
    routeCoordinates.add(Position.fromCoordinates(-118.39040499623022, 33.39696563506828));
    routeCoordinates.add(Position.fromCoordinates(-118.39005669221234, 33.39703025527067));
    routeCoordinates.add(Position.fromCoordinates(-118.38953208616074, 33.39691896489222));
    routeCoordinates.add(Position.fromCoordinates(-118.38906338075398, 33.39695127501678));
    routeCoordinates.add(Position.fromCoordinates(-118.38891287901787, 33.39686511465794));
    routeCoordinates.add(Position.fromCoordinates(-118.38898167981154, 33.39671074380141));
    routeCoordinates.add(Position.fromCoordinates(-118.38984598978178, 33.396064537239404));
    routeCoordinates.add(Position.fromCoordinates(-118.38983738968255, 33.39582400356976));
    routeCoordinates.add(Position.fromCoordinates(-118.38955358640874, 33.3955978295119));
    routeCoordinates.add(Position.fromCoordinates(-118.389041880506, 33.39578092284221));
    routeCoordinates.add(Position.fromCoordinates(-118.38872797688494, 33.3957916930261));
    routeCoordinates.add(Position.fromCoordinates(-118.38817327048618, 33.39561218978703));
    routeCoordinates.add(Position.fromCoordinates(-118.3872530598711, 33.3956265500598));
    routeCoordinates.add(Position.fromCoordinates(-118.38653065153775, 33.39592811523983));
    routeCoordinates.add(Position.fromCoordinates(-118.38638444985126, 33.39590657490452));
    routeCoordinates.add(Position.fromCoordinates(-118.38638874990086, 33.395737842093304));
    routeCoordinates.add(Position.fromCoordinates(-118.38723155962309, 33.395027006653244));
    routeCoordinates.add(Position.fromCoordinates(-118.38734766096238, 33.394441819579285));
    routeCoordinates.add(Position.fromCoordinates(-118.38785936686516, 33.39403972556368));
    routeCoordinates.add(Position.fromCoordinates(-118.3880743693453, 33.393616088784825));
    routeCoordinates.add(Position.fromCoordinates(-118.38791956755958, 33.39331092541894));
    routeCoordinates.add(Position.fromCoordinates(-118.3874852625497, 33.39333964672257));
    routeCoordinates.add(Position.fromCoordinates(-118.38686605540683, 33.39387816940854));
    routeCoordinates.add(Position.fromCoordinates(-118.38607484627983, 33.39396792286514));
    routeCoordinates.add(Position.fromCoordinates(-118.38519763616081, 33.39346171215717));
    routeCoordinates.add(Position.fromCoordinates(-118.38523203655761, 33.393196040109466));
    routeCoordinates.add(Position.fromCoordinates(-118.3849955338295, 33.393023711860515));
    routeCoordinates.add(Position.fromCoordinates(-118.38355931726203, 33.39339708930139));
    routeCoordinates.add(Position.fromCoordinates(-118.38323251349217, 33.39305243325907));
    routeCoordinates.add(Position.fromCoordinates(-118.3832583137898, 33.39244928189641));
    routeCoordinates.add(Position.fromCoordinates(-118.3848751324406, 33.39108499551671));
    routeCoordinates.add(Position.fromCoordinates(-118.38522773650804, 33.38926830725471));
    routeCoordinates.add(Position.fromCoordinates(-118.38508153482152, 33.38916777794189));
    routeCoordinates.add(Position.fromCoordinates(-118.38390332123025, 33.39012280171983));
    routeCoordinates.add(Position.fromCoordinates(-118.38318091289693, 33.38941192035707));
    routeCoordinates.add(Position.fromCoordinates(-118.38271650753981, 33.3896129783018));
    routeCoordinates.add(Position.fromCoordinates(-118.38275090793661, 33.38902416443619));
    routeCoordinates.add(Position.fromCoordinates(-118.38226930238106, 33.3889451769069));
    routeCoordinates.add(Position.fromCoordinates(-118.38258750605169, 33.388420985121336));
    routeCoordinates.add(Position.fromCoordinates(-118.38177049662707, 33.388083490107284));
    routeCoordinates.add(Position.fromCoordinates(-118.38080728551597, 33.38836353925403));
    routeCoordinates.add(Position.fromCoordinates(-118.37928506795642, 33.38717870977523));
    routeCoordinates.add(Position.fromCoordinates(-118.37898406448423, 33.3873079646849));
    routeCoordinates.add(Position.fromCoordinates(-118.37935386875012, 33.38816247841951));
    routeCoordinates.add(Position.fromCoordinates(-118.37794345248027, 33.387810620840135));
    routeCoordinates.add(Position.fromCoordinates(-118.37546662390886, 33.38847843095069));
    routeCoordinates.add(Position.fromCoordinates(-118.37091717142867, 33.39114243958559));

    mapView = (MapView) findViewById(R.id.mapView);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
  }

  @Override
  public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;

    mapboxMap.setOnMapClickListener(this);

    System.out.println("map ready");
    addLayer();

  }

  @Override
  public void onMapClick(@NonNull LatLng point) {
    if (satellite) {
      mapboxMap.setStyleUrl(Style.MAPBOX_STREETS);
      satellite = false;
    } else {
      mapboxMap.setStyleUrl(Style.SATELLITE);
      satellite = true;
    }

    mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
      @Override
      public void onMapChanged(@MapView.MapChange int change) {
        if (change == MapView.DID_FINISH_LOADING_STYLE) {
          addLayer();
        }
      }
    });
  }

  private void addLayer() {

    if (mapboxMap.getSource("tripFeatureSourceIdentifier") == null) {
      System.out.println("source null");
      Feature tripFeature = Feature.fromGeometry(LineString.fromCoordinates(routeCoordinates));
      GeoJsonSource tripLineSource = new GeoJsonSource("tripFeatureSourceIdentifier", FeatureCollection.fromFeatures(new Feature[] {tripFeature}));
      mapboxMap.addSource(tripLineSource);
    }

    if (mapboxMap.getLayer("layer") == null) {
      System.out.println("layer null");
      LineLayer layer = new LineLayer("layer", "tripFeatureSourceIdentifier");
      layer.setProperties(
        PropertyFactory.lineWidth(3f),
        PropertyFactory.lineColor(Color.rgb(255, 0, 0))
      );
      mapboxMap.addLayer(layer);
    }
  }

  @Override
  protected void onStart() {
    super.onStart();
    mapView.onStart();
  }

  @Override
  protected void onResume() {
    super.onResume();
    mapView.onResume();
  }

  @Override
  protected void onPause() {
    super.onPause();
    mapView.onPause();
  }

  @Override
  protected void onStop() {
    super.onStop();
    mapView.onStop();
  }

  @Override
  public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
  }

  @Override
  protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mapView.onSaveInstanceState(outState);
  }
}

Note that to reproduce the crash, remove if (mapboxMap.getLayer("layer") == null) { or the source null check in the code snippet above.

cc: @ivovandongen

@ivovandongen
Copy link
Contributor

@cammace The problem lies in:

@Override
  public void onMapClick(@NonNull LatLng point) {
    ...

    mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
      @Override
      public void onMapChanged(@MapView.MapChange int change) {
        if (change == MapView.DID_FINISH_LOADING_STYLE) {
          addLayer();
        }
      }
    });
  }

This adds a new listener on every map click and adds the layer multiple times. You should either add it once or remove it after execution.

The reason it crashes is that the onMapChangeListener throws a RuntimeException which cannot be handled in the onMapChanged callback. Adding a pr to fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug
Projects
None yet
2 participants