我在 Acer平板电脑中运行我的应用,每次都有应用获取崩溃,并且应用完全在三星平板电脑上运行。
02-13 09:48:05.400: D/OpenGLRenderer(7270): Flushing caches (mode 0)
02-13 09:48:07.700: D/dalvikvm(7270): GC_CONCURRENT freed 13419K, 65% free 7568K/21063K, paused 2ms+4ms
02-13 09:48:07.830: I/dalvikvm(7270): threadid=1: stack overflow on call to Landroid/widget/TextView;.onCreateDrawableState:LI
02-13 09:48:07.830: I/dalvikvm(7270): method requires 36+20+20=76 bytes, fp is 0x4001732c (44 left)
02-13 09:48:07.830: I/dalvikvm(7270): expanding stack end (0x40017300 to 0x40017000)
02-13 09:48:07.830: I/dalvikvm(7270): Shrank stack (to 0x40017300, curFrame is 0x40017500)
02-13 09:48:07.830: D/AndroidRuntime(7270): Shutting down VM
02-13 09:48:07.830: W/dalvikvm(7270): threadid=1: thread exiting with uncaught exception (group=0x40a561f8)
02-13 09:48:07.860: E/AndroidRuntime(7270): FATAL EXCEPTION: main
02-13 09:48:07.860: E/AndroidRuntime(7270): java.lang.StackOverflowError
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDrawableState(View.java:11556)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.widget.TextView.onDraw(TextView.java:4863)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.draw(View.java:10983)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10422)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.draw(View.java:10986)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10422)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10420)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10420)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10420)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.draw(View.java:10986)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.widget.FrameLayout.draw(FrameLayout.java:450)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.widget.ScrollView.draw(ScrollView.java:1524)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10422)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.draw(View.java:10986)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.widget.FrameLayout.draw(FrameLayout.java:450)
02-13 09:48:07.860: E/AndroidRuntime(7270): at android.view.View.getDisplayList(View.java:10422)
请帮我解决这个问题
答案 0 :(得分:5)
StackOverflowError
在the depth of the stack of the running program exceeds some platform or VM specific limit
时抛出。通常情况下,这只会在程序变为无限递归时发生,但也可能在正确编写(但深度递归)的程序中发生。
也许你有太多的嵌套布局。
答案 1 :(得分:3)
StackOverflowError ,就像你有15级深度一样。
如何解决:
这不容易,您只需要删除嵌套视图(布局)。因此,尽量使用相对布局。
重现StackOverflowError:
关于StackOverflowError
最烦人的事情是,我不会在所有设备上发生。旧设备(具有较少的内存,CPU功率)将出现此错误,但高端设备可能不会产生此错误。因此,生成/解决此问题的最佳方法是在不同的模拟器上进行测试。
答案 2 :(得分:2)
通常StackOverflowError
会出现,只要您有太多嵌套视图组,这些视图组在另一个内部。我认为在你的布局中保留了太多的视图并递归调用,这是递归调用另一个并导致堆内存超出特定限制。
只需使用HierarchyViewer
查看您的布局,即可告诉您如何设计布局。