My application has two tabhosts and both of them are necessary. I had to use tabhost instead of actionbar as my application need to be supported by the low-end android device.
Now, my FragmentActivity has two fragments and one of them has a ListView. The ListView loads fine but the application crashes with java.lang.StackOverflowError when I begin to scroll the list.
My layout for each row is very simple and as i told before it loads first time perfectly and crashes while its scrolled.
I put my logcat here.
12-02 15:14:26.929: E/AndroidRuntime(22971): FATAL EXCEPTION: GUI Thread
12-02 15:14:26.929: E/AndroidRuntime(22971): java.lang.StackOverflowError
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.graphics.Paint.measureText(Paint.java:1020)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.graphics.Paint.measureText(Paint.java:1057)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Styled.drawDirectionalRun(Styled.java:284)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Styled.measureText(Styled.java:447)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.measureText(Layout.java:1888)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.getLineMax(Layout.java:841)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.draw(Layout.java:386)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.BoringLayout.draw(BoringLayout.java:365)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.TextView.onDraw(TextView.java:4334)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6880)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.buildDrawingCache(View.java:6642)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.getDrawingCache(View.java:6428)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1571)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1643)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.ListView.dispatchDraw(ListView.java:3207)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6986)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.AbsListView.draw(AbsListView.java:3021)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.support.v4.view.ViewPager.draw(ViewPager.java:2153)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.FrameLayout.draw(FrameLayout.java:357)
12-02 15:14:26.929: E/AndroidRuntime(22971): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1964)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewRoot.draw(ViewRoot.java:1529)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewRoot.performTra
Related
My app is running well on version below 5. But when i run it on Nexus 7 with version 5, it crashes with following error msg
12-02 18:24:01.941: E/StrictMode(14686): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
12-02 18:24:01.941: E/StrictMode(14686): java.lang.Throwable: Explicit termination method 'close' not called
12-02 18:24:01.941: E/StrictMode(14686): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
12-02 18:24:01.941: E/StrictMode(14686): at java.io.FileInputStream.<init>(FileInputStream.java:78)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.DiskLruCache.get(DiskLruCache.java:417)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.HttpResponseCache.get(HttpResponseCache.java:164)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:190)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.seekTo(MediaHTTPConnection.java:199)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.readAt(MediaHTTPConnection.java:315)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.native_readAt(Native Method)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.readAt(MediaHTTPConnection.java:304)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.IMediaHTTPConnection$Stub.onTransact(IMediaHTTPConnection.java:72)
Can anyone suggest solution for this.
I am currently using 2 libraries in my Android project:
SlidingMenu: https://github.com/jfeinstein10/SlidingMenu
Android-PullToRefresh: https://github.com/chrisbanes/Android-PullToRefresh
With Android 4.x everything works right, but in Android 2.x I get a StackOverflow Exception.
I am not sure if it is an Android version issue or a hardware issue.
This is the log of the exception:
05-22 13:34:30.339: E/AndroidRuntime(15179): java.lang.StackOverflowError
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.text.Styled.measureText(Styled.java:430)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.text.Layout.measureText(Layout.java:1655)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.text.Layout.getLineMax(Layout.java:689)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.text.Layout.draw(Layout.java:340)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.text.BoringLayout.draw(BoringLayout.java:365)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.TextView.onDraw(TextView.java:4259)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6880)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.FrameLayout.draw(FrameLayout.java:357)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1492)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.ListView.dispatchDraw(ListView.java:3138)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6986)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.AbsListView.draw(AbsListView.java:2600)
05-22 13:34:30.339: E/AndroidRuntime(15179): at com.handmark.pulltorefresh.library.PullToRefreshListView$InternalListView.draw(PullToRefreshListView.java:281)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.buildDrawingCache(View.java:6642)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.onAnimationStart(ViewGroup.java:1259)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1505)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.support.v4.view.ViewPager.draw(ViewPager.java:1574)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.FrameLayout.draw(FrameLayout.java:357)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.FrameLayout.draw(FrameLayout.java:357)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at com.slidingmenu.lib.CustomViewAbove.dispatchDraw(CustomViewAbove.java:830)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.view.View.draw(View.java:6883)
05-22 13:34:30.339: E/AndroidRuntime(15179): at android.widget.FrameLayout.draw(FrameLayout.java:357)
Can somebody help me to solve the issue?
Thank you!
You generally see this error when you have too many nested views - a problem which is exacerbated on older versions of Android.
However, I have also noticed that the slidingmenu lib can cause this on older versions of android (3.X or earlier). I used to see this error all the time and it was originating from the slidingmenu code - my own views were only nested 10-15 deep (not great, but not disastrous). I switched to the menu-drawer library https://github.com/SimonVT/android-menudrawer and the error disappeared.
Things to try...
Fire up the android device monitor or hierarchy viewer (http://developer.android.com/tools/debugging/debugging-ui.html) and have a look at your layouts. If there are any views deeper than say, 15-20 you might want to have a look at optimizing your layouts.
Try swapping out your sliding-menu lib for either google's own (in the support lib) or the one I mentioned above (which may be easier to swap as it follows a similar design to slidingmenu - it took me about an hour).
Good luck!
I have a tabhost with 5 tabs which are FragmentActivity. One of them contains a sequence of 7 views. I think that each is a fragment, but when I get to fragment 7 the app explodes.
When I press the continue button in each fragment I start a new fragment in this way:
MyFragment newFragment = new MyFragment ();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.publish_map_direction, newFragment);
transaction.addToBackStack(null);
transaction.commit();
This is the error:
11-14 13:50:33.640: I/dalvikvm(13823): threadid=1: stack overflow on call to Landroid/text/Layout;.draw:VLLLI
11-14 13:50:33.640: I/dalvikvm(13823): method requires 288+20+60=368 bytes, fp is 0x4428a42c (300 left)
11-14 13:50:33.640: I/dalvikvm(13823): expanding stack end (0x4428a300 to 0x4428a000)
11-14 13:50:33.640: I/dalvikvm(13823): Shrank stack (to 0x4428a300, curFrame is 0x4428cc74)
11-14 13:50:33.640: D/AndroidRuntime(13823): Shutting down VM
11-14 13:50:33.640: W/dalvikvm(13823): threadid=1: thread exiting with uncaught exception (group=0x40015578)
11-14 13:50:33.703: E/AndroidRuntime(13823): FATAL EXCEPTION: main
11-14 13:50:33.703: E/AndroidRuntime(13823): java.lang.StackOverflowError
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.TextView.onDraw(TextView.java:4229)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6933)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.buildDrawingCache(View.java:6695)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.onAnimationStart(ViewGroup.java:1259)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1505)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.View.draw(View.java:6936)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-14 13:50:33.703: E/AndroidRuntime(13823): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1904)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewRoot.draw(ViewRoot.java:1527)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.os.Looper.loop(Looper.java:130)
11-14 13:50:33.703: E/AndroidRuntime(13823): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-14 13:50:33.703: E/AndroidRuntime(13823): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:50:33.703: E/AndroidRuntime(13823): at java.lang.reflect.Method.invoke(Method.java:507)
11-14 13:50:33.703: E/AndroidRuntime(13823): at com.
Should I structure my app in a different way?
Yes.
I would recommend using just fragments, instead of nesting fragment activities inside the tab host. I usually create a tab bar and just have a frame layout below it that I put a fragment in. then i replace fragments depending on what gets clicked. That should definitely help, because I think you just have too many things going at the same time.
I integrated ActionBarSherlock into my Android application. It is mostly working well, with one serious exception...
When running specifically on API Level 10 (which corresponds to Android 2.3.3), and only on that version, a StackOverflowError (shown below) is happening at a certain point when the user navigates between two particular activities. The call stack reveals that this error happens entirely within the Android framework, independent of my custom code.
The only reason I know it is related to ActionBarSherlock is that the error doesn't happen if I revert my changes to the activity classes so that they again inherit from the standard Activity base class instead of SherlockActivity, and revert to a non-Sherlock theme.
FATAL EXCEPTION: main
java.lang.StackOverflowError
at com.android.internal.util.ArrayUtils.emptyArray(ArrayUtils.java:107)
at android.text.SpannableStringInternal.getSpans(SpannableStringInternal.java:269)
at android.text.SpannedString.getSpans(SpannedString.java:25)
at android.text.Styled.drawUniformRun(Styled.java:67)
at android.text.Styled.drawDirectionalRun(Styled.java:322)
at android.text.Styled.drawText(Styled.java:381)
at android.text.Layout.drawText(Layout.java:1703)
at android.text.Layout.draw(Layout.java:505)
at android.text.BoringLayout.draw(BoringLayout.java:365)
at android.widget.TextView.onDraw(TextView.java:4431)
at android.view.View.draw(View.java:6880)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.widget.ScrollView.draw(ScrollView.java:1703)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.buildDrawingCache(View.java:6640)
at android.view.View.getDrawingCache(View.java:6428)
at android.view.ViewGroup.drawChild(ViewGroup.java:1571)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1921)
at android.view.ViewRoot.draw(ViewRoot.java:1526)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1262)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1863)
I just encountered a similar error when invalidateOptionsMenu() was being called twice in very quick succession (in onResume, and then in onPrepareOptionsMenu).
Once I removed the invalidateOptionsMenu() calls from onPrepareOptionsMenu, the issue went away. Maybe this isn't what's happening in your situation, but just thought I'd offer it as a possible solution.
The UI thread stack size on Android 2.x is smaller than Android 4.x. This means older versions are more prone to StackOverflowErrors. This explains why you only experience this on an older version.
The problem with ABS is that it automatically adds a few nested views to your layout (the main layout which holds the action bar). You can see these extra views by using Hierarchy Viewer.
If you already had a deep layout with many nested views, adding ABS probably added the extra views that filled up your stack.
What I suggest is that you simplify your layout and remove some of your extra views. There are a few tips on how to optimize layouts in the Android Developer Blog (by Romain Guy). If you save about 2-3 views, it should compensate on what ABS added and you should be fine.
I try to run this , but it force close happen like this
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): java.lang.RuntimeException: Fail to connect to camera service
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.hardware.Camera.native_setup(Native Method)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.hardware.Camera.<init>(Camera.java:294)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.hardware.Camera.open(Camera.java:271)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at com.example.Preview.surfaceCreated(Preview.java:37)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.SurfaceView.updateWindow(SurfaceView.java:543)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.SurfaceView.dispatchDraw(SurfaceView.java:348)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.View.draw(View.java:6936)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.View.draw(View.java:6936)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.widget.FrameLayout.draw(FrameLayout.java:357)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1904)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewRoot.draw(ViewRoot.java:1527)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.os.Handler.dispatchMessage(Handler.java:99)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.os.Looper.loop(Looper.java:123)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at android.app.ActivityThread.main(ActivityThread.java:3687)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at java.lang.reflect.Method.invokeNative(Native Method)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at java.lang.reflect.Method.invoke(Method.java:507)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
06-29 10:14:14.154: ERROR/AndroidRuntime(4392): at dalvik.system.NativeStart.main(Native Method)
Sounds like your device does not have a camera (emulator!) or that you dont have the appropriate permissions defined in your manifest.
android.permission.CAMERA
I think the problem is in your device, because the tutorial has ask you to add the permission. Edit your AVD and add camera support in hardware