HMS-Core / hms-mapkit-demo

HMS Map Kit demo provides an example of intergrating HMS Map Android SDK. Personalizing how your map displays and interacts with your users tailors their experience to them
https://developer.huawei.com/consumer/en/hms/huawei-MapKit?ha_source=hms1
Apache License 2.0
115 stars 43 forks source link

Crash on orientation change when map clustering is set to true and clusterable markers are being added to map #5

Closed dalmaracz closed 4 years ago

dalmaracz commented 4 years ago

Scenario:

  1. Activity1 with a button that opens MapActivity (contains a map view)
  2. Map on MapActivity has clusterable set to true. On MapActivity an api call is made to get some data and once this data is available some pins (number of pins ranges between 40 - 500) are placed on map. Pins have clusterable set to true
  3. When goin from Activity1 to MapActivity if the button that leads to MapActivity is pressed and simultaneously the screen is rotated the following crash occurs:

java.lang.NullPointerException: Attempt to invoke virtual method 'com.huawei.map.mapapi.model.Marker com.huawei.map.mapapi.HWMap.addMarker(com.huawei.map.mapapi.model.MarkerOptions)' on a null object reference at com.huawei.hms.maps.provider.markercluster.clustering.view.e$d.b(:10711) at com.huawei.hms.maps.provider.markercluster.clustering.view.e$e.handleMessage(:1880) at android.os.Handler.dispatchMessage(Handler.java:112) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) E/HmsMapKit_CrashHandler_79: uncaughtException stacktrace is java.lang.NullPointerException: Attempt to invoke virtual method 'com.huawei.map.mapapi.model.Marker com.huawei.map.mapapi.HWMap.addMarker(com.huawei.map.mapapi.model.MarkerOptions)' on a null object reference at com.huawei.hms.maps.provider.markercluster.clustering.view.e$d.b(:10711) at com.huawei.hms.maps.provider.markercluster.clustering.view.e$e.handleMessage(:1880) at android.os.Handler.dispatchMessage(Handler.java:112) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

goblinr commented 3 years ago

I have the same issue https://github.com/HMS-Core/hms-mapkit-demo-java/issues/8:

  1. Open a fragment with a map
  2. We do not allow the map to load, immediately press the "Back" button
  3. We get an application crash
java.lang.NullPointerException: Attempt to invoke virtual method 'com.huawei.map.mapapi.model.Marker com.huawei.map.mapapi.HWMap.addMarker(com.huawei.map.mapapi.model.MarkerOptions)' on a null object reference
        at com.huawei.hms.maps.provider.markercluster.clustering.view.e$d.b(:10711)
        at com.huawei.hms.maps.provider.markercluster.clustering.view.e$e.handleMessage(:1880)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8347)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
lovehuaweimaps commented 3 years ago

Thank you for your feedback, we will fix this problem in the next version as soon as possible.