2

我有一個特定的用戶在Android 4.0.3上報告一次以下的崩潰。我在堆棧中看不到任何對我的代碼的引用,我想知道是否有人對於可能導致此問題的任何想法?StackOverflowError,我想不通爲什麼

顯然,不是最高優先級,因爲它只被報告過一次,但我仍然想明白。我無法在4.0.2上重現(我無法運行4.0.3仿真器)。

謝謝

堆棧跟蹤:

java.lang.StackOverflowError 
android.text.TextLine.handleRun(TextLine.java:986) 
android.text.TextLine.measureRun(TextLine.java:430) 
android.text.TextLine.measure(TextLine.java:295) 
android.text.TextLine.metrics(TextLine.java:269) 
android.text.Layout.getLineExtent(Layout.java:947) 
android.text.Layout.draw(Layout.java:410) 
android.text.BoringLayout.draw(BoringLayout.java:400) 
android.widget.TextView.onDraw(TextView.java:5047) 
android.view.View.draw(View.java:10983) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.getDisplayList(View.java:10420) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.widget.FrameLayout.draw(FrameLayout.java:450) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.widget.AbsListView.dispatchDraw(AbsListView.java:2092) 
android.view.View.draw(View.java:10986) 
android.widget.AbsListView.draw(AbsListView.java:3398) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.widget.FrameLayout.draw(FrameLayout.java:450) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.getDisplayList(View.java:10420) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.widget.FrameLayout.draw(FrameLayout.java:450) 
android.widget.ScrollView.draw(ScrollView.java:1524) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.support.v4.view.ViewPager.draw(SourceFile:2336) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.getDisplayList(View.java:10420) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.support.v4.widget.DrawerLayout.drawChild(SourceFile:1373) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.getDisplayList(View.java:10420) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.widget.FrameLayout.draw(FrameLayout.java:450) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.getDisplayList(View.java:10420) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.view.View.getDisplayList(View.java:10422) 
android.view.ViewGroup.drawChild(ViewGroup.java:2856) 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2495) 
android.view.View.draw(View.java:10986) 
android.widget.FrameLayout.draw(FrameLayout.java:450) 
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2198) 
android.view.View.getDisplayList(View.java:10422) 
android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:849) 
android.view.ViewRootImpl.draw(ViewRootImpl.java:1942) 
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1666) 
android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2474) 
android.os.Handler.dispatchMessage(Handler.java:99) 
android.os.Looper.loop(Looper.java:137) 
android.app.ActivityThread.main(ActivityThread.java:4447) 
java.lang.reflect.Method.invokeNative(Native Method) 
java.lang.reflect.Method.invoke(Method.java:511) 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
dalvik.system.NativeStart.main(Native Method) 

這是我的主要活動的XML(如一個用戶DrawerLayout)。林特沒有報告任何重要的,我沒有看到一個明顯的問題在這裏。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <!-- To show drawer over toolbar, move this down to right above frameLayout --> 

    <include 
     android:id="@+id/app_bar" 
     layout="@layout/app_bar" /> 

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/content_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/bg_offwhite"> 

      <FrameLayout 
       android:id="@+id/main_frag_container" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       tools:context="com.nsouth.myapp.Activity_Main" 
       tools:ignore="MergeRootFrame" /> 

     </RelativeLayout> 

     <android.support.design.widget.NavigationView 
      android:id="@+id/navigation_view" 
      android:layout_width="290dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="left" 
      android:theme="@style/MyNavViewTheme" 
      app:headerLayout="@layout/nav_drawer_header" 
      app:menu="@menu/nav_drawer_menu" /> 

    </android.support.v4.widget.DrawerLayout> 

    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="80dp" 
     android:layout_marginTop="-80dp" 
     android:id="@+id/snackbarPosition"> 
    </android.support.design.widget.CoordinatorLayout> 

    <LinearLayout 
     android:id="@+id/tv_main_debug_area" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_marginTop="-40dp" 
     android:visibility="visible" 
     android:paddingLeft="10dp" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/tv_debug_pfeatures_status" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="unknown" /> 
     <TextView 
      android:id="@+id/tv_debug_pfeatures_daysremaining" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="unknown" /> 

    </LinearLayout> 

</LinearLayout> 
+0

您可能有多個嵌套佈局。 –

回答

0

肯定你有嵌套佈局,以便你得到這個錯誤。 See this question

此外還有layoutopt修復分層佈局問題,但它現在被替換lint SDK工具修訂16

後,因此,使用lint

,它可以幫助您輕鬆識別和糾正代碼的結構質量問題,並檢查您的Android項目源文件是否存在潛在錯誤並優化正確性,

+0

謝謝,我會運行'lint'並在明天深入挖掘。你知道我應該在哪裏尋找這些錯誤嗎?我在包含我的'DrawerLayout'的活動佈局中運行'lint',並沒有出現紅旗。此外,由於將偶爾的佈局嵌套到另一個佈局中並不罕見,我不確定*哪種嵌套可能會導致此問題。我用我的活動XML更新了我的問題。 – NSouth

+0

是的,你是對的,這個問題只發生在一些設備 4 -...-...版本。我知道[Hierarchy Viewer和lint工具](http://developer.android.com/tools/debugging/debugging-ui.html)有助於調試,但不幸的是,直到今天我都沒有使用這些工具,以至於我對此沒有深刻的認識。希望你能很快理解並修復它。 –

相關問題