views:

346

answers:

2

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.

+1  A: 

I run into stack traces like that when people have a TabHost in their layout but do not add TabSpecs to it. You show the code where you add tabs -- are you sure that is being called in all circumstances?

CommonsWare
The first line of code posted (`Drawable commentSelector...`) follows immediately after the only occurrence of the setting of a content view: `setContentView(R.layout.viewmovie);`. A lot of things are happening before this, so I'm guessing potentially things could go wrong leading up to that code not being executed (although it'd be remarkable if it did), but it will definitely always be executed if the content view is set to this `layout.viewmovie` which is the view that has the tabhost. That should be all that matters, in this case, right...?
David Hedlund
Yes, that should be all that matters. Is your activity a TabActivity? If not, you need to call setup() on the TabHost before adding any TabSpecs. Otherwise, nothing leaps out at me that might be awry.
CommonsWare
Hmm, I just had the user test another release of the app, where `setContentView` and the tab setup block is the first thing that happens in `onCreate`, and the user reports back that the issues have been solved, so although i haven't quite worked out what execution path the code must have followed to produce this error, i'll conclude that the issue must be of some relation to your reply. Thanks!
David Hedlund
A: 

I got the same error in my application, but only on Android 1.6 and higher - it worked on 1.5.

The reason: initial application Activity extended TabActivity but layout XML with TabHost widget was not loaded via setContentView() in onCreate() scope (it was scheduled to load via Runnable a little bit later).

Then first try to actually draw such not-fully-processed TabActivity on screen caused crash with NullPointerException at android.widget.TabWidget.dispatchDraw(TabWidget.java:173)

You have to load XML or instantiate TabHost and fill with newTabSpecs programatically before onCreate ends.

tomash

related questions