Android - stackoverflow Error
StackOverflowError usually occurs when there are too many recursive calls, so I would suggest that you check every method that would call itself very carefully, specifically conditions that would cause them to call themselves an unreasonable number of times (a few thousands), or cause a no-exit situation (infinite recursion).
For more detailed help, please post error log and other info.
goodm
AS3/Android/Unity3D Lead interactive developer in digital production company based in London.
Updated on July 24, 2022Comments
-
goodm almost 2 years
Got problem with StackOverflowError. The worse thing that right now its occur only on one device. I've tested so far on:
Samsung Galaxy SII (2.3.4)
Samsung Nexus S (4.0.3)
HTC Wildfire (2.3.7 and 2.2)
Samsung Galaxy Tab 10.1 (3.2)
...and everything is fine. But when I send app to customer and He tested it on HTC Holiday 2.3.4 its crash with this error:
java.lang.StackOverflowError at android.widget.TextView.onDraw(TextView.java:4329) at android.view.View.draw(View.java:6993) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:7105) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.widget.ScrollView.draw(ScrollView.java:1417) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.ViewGroup.drawChild(ViewGroup.java:1730) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.view.ViewGroup.drawChild(ViewGroup.java:1732) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1459) at android.view.View.draw(View.java:6996) at android.widget.FrameLayout.draw(FrameLayout.java:357) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2054) at android.view.ViewRoot.draw(ViewRoot.java:1632) at android.view.ViewRoot.performTraversals(ViewRoot.java:1335) at android.view.ViewRoot.handleMessage(ViewRoot.java:1991) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:4358) 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:849) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607) at dalvik.system.NativeStart.main(Native Method)
There is any possibility to I don't know, increase memory, etc. App is complex and everything is on TabWidget as basic activity. Error occur in one activity, where I instand using listView I use scrollview with dynamically added view.
More details:
1) The place where I have error is TabWidget, which have inside another TabWidget with Two intents.
What is better? Have TabWidget with TabWidget inside or have only one TabWidget and intent with fake tabbuttons to with the content by setContentView(...).
2) On first intent I have two ScrollViews, the first one I dynamically add the views with user pic and same data. When you tap the user, appear animation with second ScrollView, which is also dynamically fill up by more detailed user data. All view are coming from xml files.
I didn't occur this error while I was using ListView, with no Animation and to show detailed view I just change content view, by setContentView method. Should I come back to this method? Thanks for any help.
3) Why this error occurs only on one device? Unfortunately this is client device with is in USA, I'm in UK, so I got no possibility to reproduce the error.
-
Parag Chauhan over 11 years@goodm have you find any solution ?
-
goodm over 11 years@parag unfortunately I didn't, I had come back to previous working setup.
-
-
Kai about 12 yearsLooks like you have a hyper nested layout, even without the memory issue, I'd guess that the performance isn't too great. It's better to first remove some layout and see if it resolves the issue, if so, then optimize yourlayout to be less nested. For some hints, you can start here: developer.android.com/resources/articles/…
-
goodm about 12 yearsUnfortunately I can't reproduce the error. It occurs only on customer site while testing. If I will able to reproduce this kind a error, this help me much more.
-
Kai about 12 yearsWithout the ability to actually check the results of any modifications, I can only suggest you to check out Hierarchy Viewer (mobile.tutsplus.com/tutorials/android/…) and layoutopt (developer.android.com/guide/developing/debugging/…) to improve your view hierarchy and hope that it's enough to prevent StackOverflowError.
-
user606669 about 12 yearshey I am implementing the same thing and come across the same problem but mine appears on all devices, did you manage to solve the problem please post here if its resolved and how you fixed it @goodm
-
user606669 about 12 yearswell tested again and actually it appears only on htc sensation , works find on wildfire and emulator which has much lower ram than sensation.
-
goodm about 12 yearsI didn't fixed cause I don't have this device and can't reproduce the error. I have some old working version of this layout, so I just downgrade this part of my app to working version.
-
Kai about 12 years@user606669 actually there are 3 kinds of memory that we need to be concerned about: 1. device memory that is shared among all process (196MB~1GB), 2. VM(virtual machine) RAM that is available to each process(16~48MB), and 3. stack RAM (a few 100 KB to at best a few MB)