Sunday 12 February 2012

A weird crash

Someone out there has a crashy Llama, but I have no idea who. I'm getting error reports in the Android developer console that look like this:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kebab.Llama/com.kebab.Llama.LlamaUi}: java.lang.ClassCastException: android.widget.ExpandableListView$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.ExpandableListView$SavedState
at android.widget.ListView.onRestoreInstanceState(ListView.java:3768)
at android.view.View.dispatchRestoreInstanceState(View.java:6366)
at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:1302)
at android.widget.AdapterView.dispatchRestoreInstanceState(AdapterView.java:767)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1289)
at android.view.View.restoreHierarchyState(View.java:6345)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1486)
at android.app.Activity.onRestoreInstanceState(Activity.java:844)
at android.app.TabActivity.onRestoreInstanceState(TabActivity.java:58)
at android.app.Activity.performRestoreInstanceState(Activity.java:816)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1637)
... 11 more

It's related to this issue http://code.google.com/p/android/issues/detail?id=2732, and is a bug within the Android platform's code. I think I know a way to fudge around it, but since it doesn't affect all Android phones it makes it difficult to debug. The way to reproduce it is to open a tab with a ListView (e.g. Profiles), then open a tab with an ExpandableListView (e.g. the Events tab), and then cause the view to be recreated by rotating your phone or doing something funky. If your Llama crashes, please get in touch so I can send you a version which may fix it.