NPE when drawing TabWidget in android (only on HTC Magic?)
- by David Hedlund
I've received report from the user of an app I've written that he gets FC whenever starting a certain activity. I have not been able to reproduce the issue on the emulator or on my HTC Hero (running 1.5), but this user running HTC Magic (with 1.6) is facing this error every time.
What bothers me is that no single step in the stacktrace actually includes any code in my app (com.filmtipset)
01-07 00:10:26.773 I/ActivityManager( 141): Starting activity: Intent { cmp=com.filmtipset/.ViewMovie (has extras) }
01-07 00:10:27.023 D/AndroidRuntime( 2402): Shutting down VM
01-07 00:10:27.023 W/dalvikvm( 2402): threadid=3: thread exiting with uncaught exception (group=0x4001e170)
01-07 00:10:27.023 E/AndroidRuntime( 2402): Uncaught handler: thread main exiting due to uncaught exception
01-07 00:10:27.083 E/AndroidRuntime( 2402): java.lang.NullPointerException
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.widget.TabWidget.dispatchDraw(TabWidget.java:173)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.View.draw(View.java:6552)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.View.draw(View.java:6552)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1883)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewRoot.draw(ViewRoot.java:1332)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewRoot.performTraversals(ViewRoot.java:1097)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.os.Looper.loop(Looper.java:123)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at android.app.ActivityThread.main(ActivityThread.java:4320)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at java.lang.reflect.Method.invoke(Method.java:521)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
01-07 00:10:27.083 E/AndroidRuntime( 2402): at dalvik.system.NativeStart.main(Native Method)
Full dump here if I've missed anything of interest
I'm guessing, then, that there might be something wrong with my layout. It's quite verbose, so I'm posting it here, rather than pasting the whole thing on SO.
There is a tabwidget, where one tab is connected to the scrollview, svFilmInfo, and one to the linear layout llComments.
The tab host is populated as such:
Drawable commentSelector = getResources().getDrawable(R.drawable.tabcomment);
Drawable infoSelector = getResources().getDrawable(R.drawable.tabinfo);
mTabHost = getTabHost();
mTabHost.getTabWidget().setBackgroundColor(Color.BLACK);
mTabHost.addTab(mTabHost.newTabSpec("tabInfo").setIndicator("Filminfo", infoSelector).setContent(R.id.svFilmInfo));
mTabHost.addTab(mTabHost.newTabSpec("tabInfo").setIndicator("Kommentarer", commentSelector).setContent(R.id.llComments));
Since I cannot reproduce the error myself, and since I cannot find any mention in the stack trace of what might be causing the error, I don't quite know where to start troubleshooting this.
I'd appreciate any pointers.