4

我目前在我的 Android 项目中使用 2 个库:

使用 Android 4.x 一切正常,但在 Android 2.x 中,我得到了 StackOverflow 异常。

我不确定这是Android版本问题还是硬件问题。

这是异常的日志:

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)

有人可以帮我解决这个问题吗?

谢谢!

4

1 回答 1

3

当您有太多嵌套视图时,您通常会看到此错误 - 这个问题在旧版本的 Android 上更加严重。

但是,我也注意到滑动菜单库可能会在旧版本的 android(3.X 或更早版本)上导致此问题。我曾经一直看到这个错误,它源于滑动菜单代码 - 我自己的视图只嵌套了 10-15 深(不是很好,但不是灾难性的)。我切换到菜单抽屉库https://github.com/SimonVT/android-menudrawer并且错误消失了。

可以尝试的东西...

  1. 启动 android 设备监视器或层次结构查看器 ( http://developer.android.com/tools/debugging/debugging-ui.html ) 并查看您的布局。如果有任何比 15-20 更深入的视图,您可能想看看优化布局。
  2. 尝试将您的滑动菜单库换成谷歌自己的(在支持库中)或我上面提到的那个(可能更容易更换,因为它遵循与滑动菜单类似的设计 - 我花了大约一个小时)。

祝你好运!

于 2013-07-31T12:49:11.513 回答