我正在使用离线地图显示使用OSMdroid
,有时每当我尝试缩放或平移地图不可用时,我的应用程序崩溃。
这是堆栈跟踪:
07-01 13:24:01.625: E/AndroidRuntime(13443): java.lang.NullPointerException
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1083)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.graphics.Canvas.drawBitmap(Canvas.java:1201)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.tileprovider.MapTileProviderBase$ZoomInTileLooper.handleTile(MapTileProviderBase.java:343)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.tileprovider.MapTileProviderBase$ScaleTileLooper.handleTile(MapTileProviderBase.java:292)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.util.TileLooper.loop(TileLooper.java:34)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.tileprovider.MapTileProviderBase.rescaleCache(MapTileProviderBase.java:248)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.views.MapView.setZoomLevel(MapView.java:368)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.views.MapController.setZoom(MapController.java:182)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.views.MapController.onAnimationEnd(MapController.java:263)
07-01 13:24:01.625: E/AndroidRuntime(13443): at org.osmdroid.views.MapController$MyZoomAnimatorListener.onAnimationEnd(MapController.java:280)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:644)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.view.Choreographer.doFrame(Choreographer.java:543)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.os.Handler.handleCallback(Handler.java:733)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.os.Handler.dispatchMessage(Handler.java:95)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.os.Looper.loop(Looper.java:136)
07-01 13:24:01.625: E/AndroidRuntime(13443): at android.app.ActivityThread.main(ActivityThread.java:5017)
07-01 13:24:01.625: E/AndroidRuntime(13443): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 13:24:01.625: E/AndroidRuntime(13443): at java.lang.reflect.Method.invoke(Method.java:515)
07-01 13:24:01.625: E/AndroidRuntime(13443): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-01 13:24:01.625: E/AndroidRuntime(13443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-01 13:24:01.625: E/AndroidRuntime(13443): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
这是NullPointerException
。在此缩放级别,您缺少与此位置对应的磁贴,但在您的代码中不会处理此情况。
渲染器希望磁贴的Bitmap
存在,因此在尝试显示它时会崩溃。