***Error,我不知道为啥
Posted
技术标签:
【中文标题】***Error,我不知道为啥【英文标题】:***Error and I can't figure out why***Error,我不知道为什么 【发布时间】:2016-09-11 02:41:44 【问题描述】:我在 android 4.0.3 上仅报告过一次特定用户的以下崩溃。我在堆栈区域中没有看到对我的代码的引用,我想知道是否有人对可能导致此问题的原因有任何想法?
显然,不是最高优先级,因为它只被报告过一次,但我仍然想了解。我无法在 4.0.2 上重现(我无法运行 4.0.3 模拟器)。
谢谢,
堆栈跟踪:
java.lang.***Error
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
的 XML)。 Lint 没有报告任何重大问题,我在这里没有看到明显的问题。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_
android:layout_
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_
android:layout_>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_layout"
android:layout_
android:layout_
android:background="@color/bg_offwhite">
<FrameLayout
android:id="@+id/main_frag_container"
android:layout_
android:layout_
tools:context="com.nsouth.myapp.Activity_Main"
tools:ignore="MergeRootFrame" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_
android:layout_
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_
android:layout_
android:layout_marginTop="-80dp"
android:id="@+id/snackbarPosition">
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/tv_main_debug_area"
android:layout_
android:layout_
android:layout_marginTop="-40dp"
android:visibility="visible"
android:paddingLeft="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/tv_debug_pfeatures_status"
android:layout_
android:layout_
android:text="unknown" />
<TextView
android:id="@+id/tv_debug_pfeatures_daysremaining"
android:layout_
android:layout_
android:text="unknown" />
</LinearLayout>
</LinearLayout>
【问题讨论】:
你里面可能有多个嵌套布局。 【参考方案1】:确定您有嵌套布局,因此您会收到此错误。 See this question.
此外,还有 layoutopt 用于修复分层布局问题,但在 SDK 工具修订版 16 之后,它现在被 lint 取代。
所以使用lint
它可以帮助您轻松识别和纠正代码结构质量的问题,并检查您的 Android 项目源文件中的潜在错误和优化改进的正确性,
【讨论】:
谢谢,明天我会运行lint
并深入挖掘。你知道我应该在哪里寻找这些错误吗?我在包含我的DrawerLayout
的活动布局中运行lint
并且没有收到任何危险信号。此外,由于在 Android 中将偶尔的布局嵌套在另一个布局中并不少见,我不确定哪种嵌套 会导致此问题。我已经用我的活动 XML 更新了我的问题。
是的,您是对的,该问题仅出现在某些具有 4-...-... 版本的设备中。我知道Hierarchy Viewer and lint tool 有助于调试它,但不幸的是,直到今天我都没有使用这些,所以我对此没有深入的了解。希望您能理解并尽快解决。以上是关于***Error,我不知道为啥的主要内容,如果未能解决你的问题,请参考以下文章