threadid=1: thread exiting with uncaught exception (group=0x40fca9a8)的问题

Posted HaiyuKing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了threadid=1: thread exiting with uncaught exception (group=0x40fca9a8)的问题相关的知识,希望对你有一定的参考价值。

今天在项目开发中碰到了这样一个问题:

  项目在Nexus5【android 6.0】上面运行正常,在华为荣耀6【Android 4.4.2】上面运行到指定activity崩溃(不是应用启动崩溃);然后后台日志报错:

07-26 17:58:44.030: D/AndroidRuntime(10889): Shutting down VM
07-26 17:58:44.030: W/dalvikvm(10889): threadid=1: thread exiting with uncaught exception (group=0x40fca9a8)
07-26 17:58:44.050: E/AndroidRuntime(10889): FATAL EXCEPTION: main
07-26 17:58:44.050: E/AndroidRuntime(10889): java.lang.NullPointerException
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.widget.ScrollBarDrawable.setAlpha(ScrollBarDrawable.java:221)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.onDrawScrollBars(View.java:11439)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13809)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.widget.FrameLayout.draw(FrameLayout.java:467)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.widget.ScrollView.draw(ScrollView.java:1579)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12741)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13519)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12739)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13519)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13806)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12741)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13519)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1089)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12739)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13519)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12739)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13519)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12739)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13519)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.drawChild(ViewGroup.java:3019)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2883)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.draw(View.java:13806)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.widget.FrameLayout.draw(FrameLayout.java:467)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2240)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12741)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.View.getDisplayList(View.java:12785)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1249)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewRootImpl.draw(ViewRootImpl.java:2480)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2340)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2142)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4879)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.Choreographer.doCallbacks(Choreographer.java:579)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.Choreographer.doFrame(Choreographer.java:548)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.os.Handler.handleCallback(Handler.java:725)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.os.Looper.loop(Looper.java:153)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at android.app.ActivityThread.main(ActivityThread.java:5299)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at java.lang.reflect.Method.invokeNative(Native Method)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at java.lang.reflect.Method.invoke(Method.java:511)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
07-26 17:58:44.050: E/AndroidRuntime(10889):     at dalvik.system.NativeStart.main(Native Method)
07-26 17:58:44.245: I/System.out(10889): [CDS]close[39632]
07-26 17:58:44.245: I/System.out(10889): close [socket][/0.0.0.0:39632]
07-26 17:58:44.246: I/System.out(10889): close [socket][/0.0.0.0:39632]
07-26 17:58:44.712: D/dalvikvm(10889): threadid=20: interp stack at 0x54535000

问题原因:

scrollView中嵌套RecyclerView导致的。(为什么要在scrollView中嵌套RecyclerView,因为想要实现RecyclerVIew和上面的消息区域一块滑动)

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbarSize="2dp"
    android:scrollbarThumbVertical="@null"
    android:scrollbars="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <!-- 消息/公告区域 -->
        <include layout="@layout/activity_home_message" />

        <!-- RecyclerView列表 -->
        <android.support.v7.widget.RecyclerView
            android:id="@+id/home_gridview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="@dimen/home_grid_margin"
            android:layout_marginRight="@dimen/home_grid_margin"
            android:cacheColorHint="#00000000"
            android:divider="@null"
            android:listSelector="#00000000"
            android:overScrollMode="never"
            android:scrollbars="none" />
    </LinearLayout>

</ScrollView>

解决方案:

去掉ScrollView。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbarSize="2dp"
    android:scrollbarThumbVertical="@null"
    android:scrollbars="vertical" >

    <!-- 消息/公告区域 -->
    <include layout="@layout/activity_home_message" />

    <!-- RecyclerView列表 -->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/home_gridview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="@dimen/home_grid_margin"
        android:layout_marginRight="@dimen/home_grid_margin"
        android:cacheColorHint="#00000000"
        android:divider="@null"
        android:listSelector="#00000000"
        android:overScrollMode="never"
        android:scrollbars="none" />

</LinearLayout>

 

以上是关于threadid=1: thread exiting with uncaught exception (group=0x40fca9a8)的问题的主要内容,如果未能解决你的问题,请参考以下文章

threadid=1: thread exiting with uncaught exception (group=0x40fca9a8)的问题

Python 多线程,线程同步

Python 线程优先级,出列顺序,先进先出,先进后出 代码实现

16阶以下子环搜索:多核并行计算版本

当其中一个线程(chrome)异常时,Uwsgi挂起(10-60秒)

Thread 与 ThreadLocal