Android - stackoverflow错误

时间:2012-03-16 12:32:25

标签: android view scrollview stack-overflow

StackOverflowError出了问题。 现在最糟糕的事情只发生在一台设备上。 到目前为止我已经测试了:

三星Galaxy SII(2.3.4)

Samsung Nexus S(4.0.3)

HTC Wildfire(2.3.7和2.2)

三星Galaxy Tab 10.1(3.2)

......一切都很好。 但是当我向客户发送应用程序并且他在HTC Holiday 2.3.4上测试时,它就崩溃了 错误:

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)

我有可能不知道,增加记忆等。 应用程序很复杂,一切都在TabWidget上作为基本活动。 在一个活动中发生错误,我在那里使用我使用的listView 具有动态添加视图的scrollview。

更多详情:

1)我有错误的地方是TabWidget,里面有另一个 带有两个意图的TabWidget。

什么更好? TabWidget里面有TabWidget,或者只有一个 TabWidget和intent with false tabbuttons with setContentView(...)。

2)在第一个意图中我有两个ScrollViews,第一个我用用户pic和相同的数据动态添加视图。当您点击用户时,使用第二个ScrollView显示动画,这也是由更详细的用户数据动态填充的。所有视图都来自xml文件。

我在使用ListView时没有出现此错误,没有动画并显示详细视图我只是通过setContentView方法更改内容视图。我应该回到这个方法吗? 谢谢你的帮助。

3)为什么只在一台设备上发生此错误?不幸的是,这是客户端设备在美国,我在英国,所以我没有可能重现错误。

3 个答案:

答案 0 :(得分:3)

当递归调用太多时,通常会发生StackOverflowError,因此我建议您检查每个会非常小心地调用自身的方法,特别是那些会导致它们自称为不合理的次数(几千)的条件,或导致无退出情况(无限递归)。

如需更详细的帮助,请发布错误日志和其他信息。

答案 1 :(得分:0)

避免在页面选择页面内调用任何服务或方法,因为此方法会被递归调用多次,最终导致stackoverflow错误。

答案 2 :(得分:0)

有时很难找到堆栈大小较小的设备上出现的StackOverflowError。您可以阅读文章how to decrease stack size