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.
Related
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!
In my Android application's main Activity is a tabActivity and one of the tab contains another Tab activity. I load the 2nd activity with different views.
There is an error on loading the Application on the emulator.
03-11 16:28:46.463: E/AndroidRuntime(23736): FATAL EXCEPTION: main
03-11 16:28:46.463: E/AndroidRuntime(23736): java.lang.StackOverflowError
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.text.Styled.measureText(Styled.java:430)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.text.Layout.measureText(Layout.java:1655)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.text.Layout.getLineMax(Layout.java:689)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.text.Layout.draw(Layout.java:340)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.text.BoringLayout.draw(BoringLayout.java:365)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.TextView.onDraw(TextView.java:4150)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6880)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1480)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.ListView.dispatchDraw(ListView.java:3138)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.ExpandableListView.dispatchDraw(ExpandableListView.java:229)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6986)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.AbsListView.draw(AbsListView.java:2584)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.FrameLayout.draw(FrameLayout.java:357)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.FrameLayout.draw(FrameLayout.java:357)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.FrameLayout.draw(FrameLayout.java:357)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.FrameLayout.draw(FrameLayout.java:357)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.View.draw(View.java:6883)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.widget.FrameLayout.draw(FrameLayout.java:357)
03-11 16:28:46.463: E/AndroidRuntime(23736): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1862)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewRoot.draw(ViewRoot.java:1522)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
03-11 16:28:46.463: E/AndroidRuntime(23736): at android.view.ViewRoot.handleMessage(ViewR
Thrown when the depth of the stack of the running program exceeds some platform or VM specific limit. Typically, this will occur only when a program becomes infinitely recursive, but it can also occur in correctly written (but deeply recursive) programs.
More Details
Most likely in your child activity you are trying to load the first activity again, which loads the second activity, which again loads the first activity and so on, leading to recursion and your app dies because it reaches the memory limit, applied by the OS.
I am developing Camera overly app in that i am using camera api for preview and overlay effects.I am getting force close error in some mobiles and it is not happening other mobiles.
My code:
parameters = camera.getParameters();
List<Size> sizes = parameters.getSupportedPreviewSizes();
Size optimalSize = getOptimalPreviewSize(sizes, w, h);
parameters.setPreviewSize(optimalSize.width, optimalSize.height);
parameters.setColorEffect(Camera.Parameters.EFFECT_SOLARIZE);
setCameraDisplayOrientation(MainActivity.this,0, camera);
camera.getParameters();
camera.setParameters(parameters);
These are the call stacks I am getting
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:1046)
at com.androidpixels.watercamera.MainActivity.surfaceChanged(MainActivity.java:1241)
at android.view.SurfaceView.updateWindow(SurfaceView.java:575)
at android.view.SurfaceView.updateWindow(SurfaceView.java:407)
at android.view.SurfaceView.dispatchDraw(SurfaceView.java:352)
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:6936)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1917)
at android.view.ViewRoot.draw(ViewRoot.java:1530)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1266)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1868)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3693)
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:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
Please help me. what could be the reason?
Android Camera Parameters vary between devices. you need to verify that the device supports the parameter you're trying to set before setting it, see this Camera SetParameters Doc
You can query the Supported Parameters by :
Obtain a Parameters object : Camera.Parameters params = mCamera.getParameters();
Then query that object for specific Parameter , say PreviewSize:
params.getSupportedPreviewSizes ()
I am displaying one .gif in my activity A. When user presses one button user moves to activity b and same .gif is displaying there but I am getting "trying to use a recycled bitmap android.graphics.Bitmap" this error on my activity b.
I am displaying .gif from sd card and on onStop() I am setting imageview of activity a to null as well in activity A but I am not able to solve this issue.
Please help in this case.
//Log Cat
12-31 10:58:49.819: E/AndroidRuntime(20903): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap#405131c8
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.graphics.Canvas.throwIfRecycled(Canvas.java:955)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.graphics.Canvas.drawBitmap(Canvas.java:1044)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:325)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.widget.ImageView.onDraw(ImageView.java:854)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.View.draw(View.java:6880)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.View.draw(View.java:6883)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.View.draw(View.java:6883)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.widget.FrameLayout.draw(FrameLayout.java:357)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.View.draw(View.java:6883)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.widget.FrameLayout.draw(FrameLayout.java:357)
12-31 10:58:49.819: E/AndroidRuntime(20903): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1871)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewRoot.draw(ViewRoot.java:1542)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewRoot.performTraversals(ViewRoot.java:1269)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.view.ViewRoot.handleMessage(ViewRoot.java:1883)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.os.Handler.dispatchMessage(Handler.java:99)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.os.Looper.loop(Looper.java:130)
12-31 10:58:49.819: E/AndroidRuntime(20903): at android.app.ActivityThread.main(ActivityThread.java:3737)
12-31 10:58:49.819: E/AndroidRuntime(20903): at java.lang.reflect.Method.invokeNative(Native Method)
12-31 10:58:49.819: E/AndroidRuntime(20903): at java.lang.reflect.Method.invoke(Method.java:507)
12-31 10:58:49.819: E/AndroidRuntime(20903): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894)
12-31 10:58:49.819: E/AndroidRuntime(20903): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
12-31 10:58:49.819: E/AndroidRuntime(20903): at dalvik.system.NativeStart.main(Native Method)
You can have check before recycling the bitmap, as like :
if (img != null && !img.isRecycled())
{
img.recycle();
img = null;
System.gc();
}
Here img is bitmap.
Try this type error is solved.
Try to find references of usage of the method recycle() in your code or in any library that you use. It indicates that someone is recycling a bitmap that is still being used which is not good. You can only safely call the recycle() method when you are absolutely sure that the given bitmap won't be necessary anymore.
It is usually a common problem when you are dealing with bitmap caches, not sure if that is your case.
Solution already provided here : Canvas: trying to use a recycled bitmap android.graphics.Bitmap in android
This one should work . Otherwise checkout the link for more solutions
if (mBitmap != null && !mBitmap.isRecycled()) {
mBitmap.recycle();
mBitmap = null;
}
I'm having a crash when refreshing a view inside a SlidingTray (custom SlidingDrawer coming from the top).
I'm not sure what causing it.. but my first guess is that it's due to the number of nested layouts...
What is the maximum number of nested layouts?
Is it device specific, how can I be sure if that's the cause?
If it's not, any of these things is causing it.. what is?
The stacktrace:
E/AndroidRuntime( 2199): FATAL EXCEPTION: main
E/AndroidRuntime( 2199): java.lang.StackOverflowError
E/AndroidRuntime( 2199): at android.graphics.Paint.measureText(Paint.java:1057)
E/AndroidRuntime( 2199): at android.text.Styled.drawDirectionalRun(Styled.java:267)
E/AndroidRuntime( 2199): at android.text.Styled.measureText(Styled.java:430)
E/AndroidRuntime( 2199): at android.text.Layout.measureText(Layout.java:1655)
E/AndroidRuntime( 2199): at android.text.Layout.getLineMax(Layout.java:689)
E/AndroidRuntime( 2199): at android.text.Layout.draw(Layout.java:340)
E/AndroidRuntime( 2199): at android.text.BoringLayout.draw(BoringLayout.java:365)
E/AndroidRuntime( 2199): at android.widget.TextView.onDraw(TextView.java:4168)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6880)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.widget.ScrollView.draw(ScrollView.java:1409)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.buildDrawingCache(View.java:6640)
E/AndroidRuntime( 2199): at android.view.View.getDrawingCache(View.java:6428)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1571)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1392)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.widget.ScrollView.draw(ScrollView.java:1409)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6986)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.widget.HorizontalScrollView.draw(HorizontalScrollView.java:1409)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at com.vodafone.onm.components.SlidingTray.dispatchDraw(SlidingTray.java:426)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
E/AndroidRuntime( 2199): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
E/AndroidRuntime( 2199): at android.view.View.draw(View.java:6883)
E/AndroidRuntime( 2199): at android.widget.FrameLayout.draw(FrameLayout.java:357)
E/AndroidRuntime( 2199): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java)
UPDATE:
Hierarchy Viewer Snapshot
http://d.pr/kXnp
.
Some thinks I think are related:
http://www.mail-archive.com/android-developers#googlegroups.com/msg48036.html
What is the maximum number of nested layouts?
There is no specific value. You run out of stack space when you run out of stack space, and that will be contingent upon what you are doing. The main application thread has an 8KB stack, last I heard.
That being said, if Hierarchy View is showing a depth of 10 or more (root to deepest leaf), I start to get nervous, and by 15 you are likely to start running into exceptions. Your image, which is nearly illegible, appears to have a depth substantially higher than that.
You seem to have a number of wasted layers. If you have a layer in Hierarchy View, on the critical path, that has one parent and one child, that is a prime candidate to be removed, as it may not be adding any value. You have at least 5 of these candidates. Even cleaning all of that up may not be sufficient, but it is a starting point.