I'm a novice android programmer.
Let me give some context.
My project uses ActionBarSherlock.
The problem:
What I've tried so far:
So, in summary. The crash occurs when going from an activity (Activity1) with a currently showing mapview to another activity (Activity2) that also hosts a fragment containing another mapview. But the crash does not occur when going from the list fragment showing in (Activity1) to the other activity (Activity2) containing another map fragment.
I hope this is enough detail. If you have any questions, comment please.
D/memalloc( 121): /dev/pmem: Allocated buffer base:0x4215c000 size:2088960 offset:4177920 fd:66
D/memalloc(30944): /dev/pmem: Mapped buffer base:0x5b4f5000 size:6266880 offset:4177920 fd:164
D/AndroidRuntime(30944): Shutting down VM
W/dalvikvm(30944): threadid=1: thread exiting with uncaught exception (group=0x40aaa228)
E/AndroidRuntime(30944): FATAL EXCEPTION: main
E/AndroidRuntime(30944): java.lang.IllegalStateException: Map has zero size
E/AndroidRuntime(30944): at android_maps_conflict_avoidance.com.google.googlenav.map.Map.drawMap(Map.java:818)
E/AndroidRuntime(30944): at com.google.android.maps.MapView.drawMap(MapView.java:1091)
E/AndroidRuntime(30944): at com.google.android.maps.MapView.onDraw(MapView.java:522)
E/AndroidRuntime(30944): at android.view.View.draw(View.java:11071)
E/AndroidRuntime(30944): at android.view.View.getDisplayList(View.java:10462)
E/AndroidRuntime(30944): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
E/AndroidRuntime(30944): at android.view.View.getDisplayList(View.java:10425)
E/AndroidRuntime(30944): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
E/AndroidRuntime(30944): at android.view.View.getDisplayList(View.java:10425)
E/AndroidRuntime(30944): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
E/AndroidRuntime(30944): at android.view.View.getDisplayList(View.java:10425)
E/AndroidRuntime(30944): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
E/AndroidRuntime(30944): at android.view.View.getDisplayList(View.java:10425)
E/AndroidRuntime(30944): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
E/AndroidRuntime(30944): at android.view.View.getDisplayList(View.java:10425)
E/AndroidRuntime(30944): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:879)
E/AndroidRuntime(30944): at android.view.ViewRootImpl.draw(ViewRootImpl.java:1948)
E/AndroidRuntime(30944): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1654)
E/AndroidRuntime(30944): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2498)
E/AndroidRuntime(30944): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(30944): at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(30944): at android.app.ActivityThread.main(ActivityThread.java:4894)
E/AndroidRuntime(30944): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(30944): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(30944): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(30944): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(30944): at dalvik.system.NativeStart.main(Native Method)
E/EmbeddedLogger( 254): App crashed! Process: com.myapp.android
E/EmbeddedLogger( 254): App crashed! Package: com.myapp.android v5 (2.0)
E/EmbeddedLogger( 254): Application Label: myapp
W/ActivityManager( 254): Force finishing activity com.myapp.android/.activity.InfoActivity
W/ActivityManager( 254): Force finishing activity com.myapp.android/.activity.SearchActivity
At this point in my experience, the only way to avoid this bug, is to not use MapViews inside Fragments. Moving a MapView around at all by whether animation or tampering with it's position once it's been added to a parent view has always caused me problems. The most effective way I've found is to toggle between a map and another view where the MapActivity manages the MapView and a fragment manages the other View. I reimplemented the same feature again, and this has worked with no problems. However, I would observe that this is a workaround for an issue with an unknown cause (very likely a bug in the android maps API).