今天发现了我的微信发生闪退(一旦出现则会持续闪退一段时间),但无法稳定重现 (现在可稳定重现了,重启手机也解决不了)。刚好我在其中两次闪退中使用 logcat 工具记录下了闪退时的 log 信息,现附上闪退过程及详细 log 信息:

0522 update: 现在不是偶发闪退,是偶尔才能正常打开了。。。

过程:

1、点击微信图标打开微信
2、微信打开欢迎界面(有月亮背景的图片)
3、微信显示会话列表
4、微信闪退(在手机上表现和点击 home 键隐藏类似,有退出动画,但没有出现任何提示信息)
在点击微信图标后我没有对手机进行任何操作

环境:

使用的手机及网络环境:
手机型号:魅族 MX4
手机系统:Flyme OS 4.2.2.2C (Android 4.4.2)
网络环境:通过 WIFI 链接无线路由器(无线路由器使用的是中国电信 3G 网络,因此网络信号并不十分稳定)

相关 log :

共记录了三次 Log(由于无法获取各个 log 的应用名,因此所有 log 均没有经过任何过滤):
wechat_crash_logs.zip
wechat_log1_crash.log:其中一次 crash 的 log ,crash 相关 log 在 1541 行及 6638 行
wechat_log2_crash.log:从未启动微信到启动微信->闪退全过程的 Log 。crash 相关 log 在 7814 行左右开始出现
wechat_log3_normal:从未启动到启动微信->到达会话列表后还能正常使用的 log 。没有发生闪退。

第一次闪退:
wechat_log1_crash.log(节选)

...
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/ConnectivityService(  813): getActiveNetworkInfo:NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "3G_chj", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0/10069
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperator simId = 0getSimOperator = 46000
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
V/ActivityManager(  813): Broadcast: Intent { act=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver flg=0x10 cmp=com.tencent.mm/.plugin.report.service.KVCommCrossProcessReceiver (has extras) } ordered=false userid=0 callerApp=ProcessRecord{43019f38 3304:com.tencent.mm:push/u0a69}
D/ActivityThread(25391): BDC-Calling onReceive: intent=Intent { act=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver flg=0x10 cmp=com.tencent.mm/.plugin.report.service.KVCommCrossProcessReceiver (has extras) }, ordered=true, receiver=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver@44cab4e8
D/ActivityThread(25391): BDC-RECEIVER handled : 0 / ReceiverData{intent=Intent { act=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver flg=0x10 cmp=com.tencent.mm/.plugin.report.service.KVCommCrossProcessReceiver (has extras) } packageName=com.tencent.mm resultCode=-1 resultData=null resultExtras=null}
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/dalvikvm(25391): threadid=15: exiting
W/dalvikvm(25391): threadid=15: thread exiting with uncaught exception (group=0x41da8cf8)
W/dalvikvm(25391): threadid=15: uncaught exception occurred
W/System.err(25391): java.lang.NullPointerException
W/System.err(25391):    at com.tencent.mm.plugin.exdevice.b.aa.a(SourceFile:71)
W/System.err(25391):    at com.tencent.mm.q.y.run(SourceFile:95)
W/System.err(25391):    at com.tencent.mm.sdk.platformtools.ai.run(SourceFile:103)
W/System.err(25391):    at android.os.Handler.handleCallback(Handler.java:808)
W/System.err(25391):    at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err(25391):    at com.tencent.mm.sdk.platformtools.af.dispatchMessage(SourceFile:116)
W/System.err(25391):    at android.os.Looper.loop(Looper.java:193)
W/System.err(25391):    at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err(25391):    at com.tencent.mm.sdk.h.a$a.run(SourceFile:71)
W/dalvikvm(25391): threadid=15: calling UncaughtExceptionHandler
I/dalvikvm(25391): +++ calling Ljava/lang/ThreadGroup;.uncaughtException
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperator simId = 0getSimOperator = 46000
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/ConnectivityService(  813): getActiveNetworkInfo:NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "3G_chj", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0/10069
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
V/ActivityManager(  813): Broadcast: Intent { act=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver flg=0x10 cmp=com.tencent.mm/.plugin.report.service.KVCommCrossProcessReceiver (has extras) } ordered=false userid=0 callerApp=ProcessRecord{43019f38 3304:com.tencent.mm:push/u0a69}
D/AALService(  245): enableAALEvent: 0 -> 0
D/ActivityThread(25391): BDC-Calling onReceive: intent=Intent { act=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver flg=0x10 cmp=com.tencent.mm/.plugin.report.service.KVCommCrossProcessReceiver (has extras) }, ordered=true, receiver=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver@44cb6c90
D/ActivityThread(25391): BDC-RECEIVER handled : 0 / ReceiverData{intent=Intent { act=com.tencent.mm.plugin.report.service.KVCommCrossProcessReceiver flg=0x10 cmp=com.tencent.mm/.plugin.report.service.KVCommCrossProcessReceiver (has extras) } packageName=com.tencent.mm resultCode=-1 resultData=null resultExtras=null}
...

第二次闪退(节选):

D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/ConnectivityService(  813): getActiveNetworkInfo:NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "3G_chj", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false, simId: 0/10069
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/dalvikvm( 3304): threadid=26: bye!
D/dalvikvm( 3304): threadid=26: interp stack at 0x7b498000
D/PowerManagerService(  813): acquireWakeLockInternal: lock=1129546040, flags=0x1, tag="!32@/B4Tb64lLpLSCksk5w/QSxQTciH9sVsR", ws=null, uid=10069, pid=3304
D/PowerManagerService(  813): newScreenState = 2
D/PowerManagerService(  813): Package Lib: shouldUseProximitySensorLocked mLidMode = false
D/PowerManagerDisplayController(  813):  changed is false
D/PhoneInterfaceManagerEx( 1040): [PhoneIntfMgrEx] hasIccCard  simId=0
D/dalvikvm( 3304): threadid=26: bye!
D/PhoneInterfaceManager( 1040): getSimOperatorName simId = 0prop = CMCC
D/dalvikvm(25622): threadid=16: exiting
W/dalvikvm(25622): threadid=16: thread exiting with uncaught exception (group=0x41da8cf8)
W/dalvikvm(25622): threadid=16: uncaught exception occurred
W/System.err(25622): java.lang.NullPointerException
W/System.err(25622):    at com.tencent.mm.plugin.exdevice.b.aa.a(SourceFile:71)
W/System.err(25622):    at com.tencent.mm.q.y.run(SourceFile:95)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.ai.run(SourceFile:103)
W/System.err(25622):    at android.os.Handler.handleCallback(Handler.java:808)
W/System.err(25622):    at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.af.dispatchMessage(SourceFile:116)
W/System.err(25622):    at android.os.Looper.loop(Looper.java:193)
W/System.err(25622):    at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err(25622):    at com.tencent.mm.sdk.h.a$a.run(SourceFile:71)
W/dalvikvm(25622): threadid=16: calling UncaughtExceptionHandler
I/dalvikvm(25622): +++ calling Ljava/lang/ThreadGroup;.uncaughtException
D/AndroidRuntime(25622): Shutting down VM
W/dalvikvm(25622): threadid=1: thread exiting with uncaught exception (group=0x41da8cf8)
W/dalvikvm(25622): threadid=1: uncaught exception occurred
W/System.err(25622): junit.framework.AssertionFailedError: DB has been closed :[java.lang.NullPointerException
W/System.err(25622):    at com.tencent.mm.plugin.exdevice.b.aa.a(SourceFile:71)
W/System.err(25622):    at com.tencent.mm.q.y.run(SourceFile:95)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.ai.run(SourceFile:103)
W/System.err(25622):    at android.os.Handler.handleCallback(Handler.java:808)
W/System.err(25622):    at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.af.dispatchMessage(SourceFile:116)
W/System.err(25622):    at android.os.Looper.loop(Looper.java:193)
W/System.err(25622):    at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err(25622):    at com.tencent.mm.sdk.h.a$a.run(SourceFile:71)
W/System.err(25622): ]
D/dalvikvm(25622): create interp thread : stack size=128KB
D/dalvikvm(25622): create new thread
D/dalvikvm(25622): new thread created
D/dalvikvm(25622): update thread list
D/dalvikvm(25622): threadid=42: interp stack at 0x828c6000
W/System.err(25622):    at junit.framework.Assert.fail(Assert.java:50)
W/System.err(25622):    at junit.framework.Assert.assertTrue(Assert.java:20)
D/dalvikvm(25622): threadid=42: created from interp
W/System.err(25622):    at com.tencent.mm.aq.g.isOpen(SourceFile:148)
D/dalvikvm(25622): start new thread
W/System.err(25622):    at com.tencent.mm.aq.g.rawQuery(SourceFile:198)
W/System.err(25622):    at com.tencent.mm.ag.i.MZ(SourceFile:31)
D/dalvikvm(25622): threadid=42: notify debugger
D/dalvikvm(25622): threadid=42 (TbsHandlerThread): calling run()
W/System.err(25622):    at com.tencent.mm.ui.bk.run(SourceFile:525)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.ai.run(SourceFile:103)
W/System.err(25622):    at android.os.Handler.handleCallback(Handler.java:808)
W/System.err(25622):    at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.af.dispatchMessage(SourceFile:116)
W/System.err(25622):    at android.os.Looper.loop(Looper.java:193)
W/System.err(25622):    at android.app.ActivityThread.main(ActivityThread.java:5332)
W/System.err(25622):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(25622):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(25622):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
W/System.err(25622):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
W/System.err(25622):    at dalvik.system.NativeStart.main(Native Method)
W/dalvikvm(25622): threadid=1: calling UncaughtExceptionHandler
I/dalvikvm(25622): +++ calling Ljava/lang/ThreadGroup;.uncaughtException
W/dalvikvm(25622): threadid=1: calling UncaughtExceptionHandler done
D/dalvikvm(25622): threadid=1: bye!
D/dalvikvm(25622): DestroyJavaVM waiting for non-daemon threads to exit

个人分析(纯属个人分析,由于没有源码,无法完全确定)

闪退原因为下面的语句:

W/System.err(25622): java.lang.NullPointerException
W/System.err(25622):    at com.tencent.mm.plugin.exdevice.b.aa.a(SourceFile:71)
W/System.err(25622):    at com.tencent.mm.q.y.run(SourceFile:95)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.ai.run(SourceFile:103)
W/System.err(25622):    at android.os.Handler.handleCallback(Handler.java:808)
W/System.err(25622):    at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err(25622):    at com.tencent.mm.sdk.platformtools.af.dispatchMessage(SourceFile:116)
W/System.err(25622):    at android.os.Looper.loop(Looper.java:193)
W/System.err(25622):    at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err(25622):    at com.tencent.mm.sdk.h.a$a.run(SourceFile:71)

至于具体为何会有这个错误、是否这个错误导致了闪退,只能通过源码来 debug 追踪了。我手上没有源码,只能到此为止了。


↙↙↙阅读原文可查看相关链接,并与作者交流