Android Google maps crash when offline
I have a application that is about finished. When the phone is online everything works as it should.
Since the application is soon to be released i tested it when the phone is offline. This makes it crash.
After some debugging i found out that if i do not add any overlays it does not crash. ( i just get the grid, and that i can understand ;D )
As soon as a overlay tries to draw something it crashes. This even includes the provided overlay "MyLocationOverlay", which crashes as soon as the GPS gets a fix (and therefore tries to draw the user location).
is there anything i am missing?
EDIT By popular demand ;) stack trace
I am sure that i do not add null objects into the overlay, which was the first thing i checked for
02-27 15:12:53.254: WARN/dalvikvm(5376): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): FATAL EXCEPTION: main
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): java.lang.NullPointerException
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.google.android.maps.ItemizedOverlay.getItemsAtLocation(ItemizedOverlay.java:617)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.google.android.maps.ItemizedOverlay.getItemAtLocation(ItemizedOverlay.java:586)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.google.android.maps.ItemizedOverlay.handleMotionEvent(ItemizedOverlay.java:498)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.google.android.maps.ItemizedOverlay.onTouchEvent(ItemizedOverlay.java:572)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.google.android.maps.OverlayBundle.onTouchEvent(OverlayBundle.java:63)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.google.android.maps.MapView.onTouchEvent(MapView.java:643)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.View.dispatchTouchEvent(View.java:3765)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:905)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:871)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:871)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:871)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:871)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1701)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1116)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.app.Activity.dispatchTouchEvent(Activity.java:2093)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1685)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.view.ViewRoot.handleMessage(ViewRoot.java:1802)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.os.Looper.loop(Looper.java:144)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at android.app.ActivityThread.main(ActivityThread.java:4937)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at java.lang.reflect.M开发者_如何学运维ethod.invokeNative(Native Method)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at java.lang.reflect.Method.invoke(Method.java:521)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-27 15:12:53.264: ERROR/AndroidRuntime(5376): at dalvik.system.NativeStart.main(Native Method)
I had the same problem, I solved it by making sure that the overlay that I added actually has items on it. When adding overlays without items I get the same stacktrace you got and application stops working with a forced close.
This is on android 2.1, and might be fixed on other versions.
精彩评论