首页 > 其他 > 详细

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

时间:2017-07-26 20:02:05      阅读:373      评论:0      收藏:0      [点我收藏+]

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

  项目在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)的问题

原文:http://www.cnblogs.com/whycxb/p/7241538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!