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

App crashes on orientation change (NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference) #4

Closed dalmaracz closed 4 years ago

dalmaracz commented 4 years ago

Steps to reproduce:

  1. Open demo app
  2. On main page click on "LocationSourceDemo" and rapidly rotate the screen (before map gets to be created on next screen, you have to almost simultaneously click on button and rotate the screen)
  3. App crashes with following stack trace:

2020-07-02 12:46:29.841 21933-21933/com.huawei.hms.maps.sample E/AndroidRuntime: FATAL EXCEPTION: main Process: com.huawei.hms.maps.sample, PID: 21933 java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference at android.view.ViewConfiguration.get(ViewConfiguration.java:447) at android.view.View.(View.java:4850) at android.view.View.(View.java:4992) at android.widget.ImageView.(ImageView.java:198) at android.widget.ImageView.(ImageView.java:193) at com.huawei.map.utils.ao.(:52) at com.huawei.map.utils.ah.n(:194) at com.huawei.map.utils.ah.g(:670) at com.huawei.map.utils.v.a(:513) at com.huawei.map.mapapi.HWMap.setLocationSource(:437) at com.huawei.hms.maps.provider.huawei.e.c(:1930) at com.huawei.hms.maps.internal.d$d.onTransact(:628) at android.os.Binder.transact(Binder.java:675) at com.huawei.hms.maps.internal.IHuaweiMapDelegate$Stub$Proxy.setLocationSource(IHuaweiMapDelegate.java:1730) at com.huawei.hms.maps.HuaweiMap.setLocationSource(HuaweiMap.java:1319) at com.huawei.hms.maps.sample.LocationSourceDemoActivity.onMapReady(LocationSourceDemoActivity.java:119) at com.huawei.hms.maps.SupportMapFragment$SupportMapFragmentLifecycleDelegate$1.onMapReady(SupportMapFragment.java:525) at com.huawei.hms.maps.internal.IOnMapReadyCallback$Stub.onTransact(IOnMapReadyCallback.java:51) at android.os.Binder.transact(Binder.java:675) at com.huawei.hms.maps.internal.x$b$d.e(:87) at com.huawei.hms.maps.provider.huawei.SupportMapFragmentImpl$4.onMapReady(:206) at com.huawei.map.mapapi.SupportMapFragment$HWOnMapReadyCallback$1.run(:234) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) 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) 2020-07-02 12:46:29.842 21933-21933/com.huawei.hms.maps.sample E/HmsMapKit_CrashHandler_79: uncaughtException stacktrace is java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference at android.view.ViewConfiguration.get(ViewConfiguration.java:447) at android.view.View.(View.java:4850) at android.view.View.(View.java:4992) at android.widget.ImageView.(ImageView.java:198) at android.widget.ImageView.(ImageView.java:193) at com.huawei.map.utils.ao.(:52) at com.huawei.map.utils.ah.n(:194) at com.huawei.map.utils.ah.g(:670) at com.huawei.map.utils.v.a(:513) at com.huawei.map.mapapi.HWMap.setLocationSource(:437) at com.huawei.hms.maps.provider.huawei.e.c(:1930) at com.huawei.hms.maps.internal.d$d.onTransact(:628) at android.os.Binder.transact(Binder.java:675) at com.huawei.hms.maps.internal.IHuaweiMapDelegate$Stub$Proxy.setLocationSource(IHuaweiMapDelegate.java:1730) at com.huawei.hms.maps.HuaweiMap.setLocationSource(HuaweiMap.java:1319) at com.huawei.hms.maps.sample.LocationSourceDemoActivity.onMapReady(LocationSourceDemoActivity.java:119) at com.huawei.hms.maps.SupportMapFragment$SupportMapFragmentLifecycleDelegate$1.onMapReady(SupportMapFragment.java:525) at com.huawei.hms.maps.internal.IOnMapReadyCallback$Stub.onTransact(IOnMapReadyCallback.java:51) at android.os.Binder.transact(Binder.java:675) at com.huawei.hms.maps.internal.x$b$d.e(:87) at com.huawei.hms.maps.provider.huawei.SupportMapFragmentImpl$4.onMapReady(:206) at com.huawei.map.mapapi.SupportMapFragment$HWOnMapReadyCallback$1.run(:234) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) 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)

dalmaracz commented 4 years ago

Have you managed to fix this issue? And if so should I update map kit/hms?

Mike-mei commented 4 years ago

This issue will be resolved in HMS Core APK 5.0.1, the release time is 15th August. We will update the repository at once when the new version is released.