tags:

views:

110

answers:

1

I have a layout that creates a ListActivity. Before displaying the ListActivity, I perform a database query, and then hook that data up to the List using a SimpleCursorAdapter.

All of this works fine on 1.6 and higher. On 1.5, the my function that performs the query successfully executes, but then a few seconds later a StackOverflowError takes place. Does anyone know why this error would occur in 1.5 but not in 1.6?

UPDATE: I have determined that the crash occurs when I move from an Activity with a TabView to an Activity with the ListView. If I go to the ListView from an Activity that does not contain a Tab View, then the crash does not occur. The activity with the ListView is returning a Cursor to a query where the database has about 10 columns. Of those 10 columns, I display 3 columns on the screen.

Here is the flow of execution for my code:

TabView Activity sends Intent to start List View Activity

onCreate() //of ListActivity
{
    showList();
}

showList()
{
    //open DataBase
    //perform query
    //create SimpleCursorAdapter
    //setListAdapter
}

So for example, this runs completely fine on a Droid with 2.1 installed and on an emulator targeting 1.6. But the above fails on the HTC Hero with 1.5 and on an emulator targeting 1.5.

The crash happens if I let setListAdapter execute. If that line is out, everything works, but obviously my data does not get shown. It doesn't crash on the line that calls setListAdapter, but it'll eventually crash if setListAdapter is ever executed.

Stack Trace:

Thread [<3> main] (Suspended (exception StackOverflowError))

ViewRoot.draw(boolean) line: 1235   
ViewRoot.performTraversals() line: 1030 
ViewRoot.handleMessage(Message) line: 1482  
ViewRoot(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 123 
ActivityThread.main(String[]) line: 3948    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 521  
ZygoteInit$MethodAndArgsCaller.run() line: 782  
ZygoteInit.main(String[]) line: 540 
NativeStart.main(String[]) line: not available [native method]  
+2  A: 

Maybe this error is not caused by database.

Actually this error often occurs when you have too deep Layout hierarchy.

For 1.5 it could be 13 levels deep. Maybe try to check it with Hierarchy Viewer.

Also publishing stack trace might help.

UPDATE: Stacktrace is pointing clearly that problem lies in your rows layout. When you comment out setting adapter your rows aren't drawn thus error does not occur.

Maybe you are nesting too many LinearLayout's in your rows? Try to make simple rows - if problem will vanish, you will know what to repair.

Also consider moving from LinearLayout to RelativeLayout. It flattens your view hierarchy. Although take into account that RelativeLayout has some bugs eg. RelativeLayout differences between 1.5 and 2.1.

pixel
Hi pixel, I agree that I don't believe it to be a database issue but rather a layout problem. Before yesterday I didn't realize how resource-intensive a Tab View was.Thanks for pointing out the Hierarchy Viewer, I'll give that a try.The stack trace just shows a crash in the draw method (which I believe points to the layout), I'll edit the post and put the trace there also.
Michael
The default stack size was increased from 8K to 12K in 1.6 ("donut"). There's no explicit "13 level" limit, though it may happen to work out to that.
fadden