.net开发安卓从入门到放弃 最后的挣扎(排查程序闪退问题记录-到目前为止仍在继续)

ps:写在前面,这里只是记录一些方法,如果您有不同于这里的方法,希望能留言,给我指明方向!
以下的这些方法能够查到一些端倪,但是没办法定位到问题的位置,所以到写这个记录的时候还没有解决闪退问题。

logcat

导出日志到文件
adb logcat -v time >d:\b10.txt

程序包名

com.BOSHIAC.agvapp

先看日志(以下日志是多次闪退记录的系统日志,挑拣几次有代表性的发上来)

最近一次闪退

03-30 23:50:48.597 E/KernelCpuSpeedReader( 1532): Failed to read cpu-freq: /sys/devices/system/cpu/cpu6/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)
03-30 23:50:48.598 E/KernelCpuSpeedReader( 1532): Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)
03-31 00:00:00.015 D/DevicePolicyManager( 1532): updateSystemUpdateFreezePeriodsRecord
03-31 00:00:00.043 W/BroadcastQueue( 1532): Background execution not allowed: receiving Intent { act=android.intent.action.DATE_CHANGED flg=0x20200010 } to com.android.calendar/.widget.CalendarAppWidgetService$CalendarFactory
03-31 00:00:00.064 W/BroadcastQueue( 1532): Background execution not allowed: receiving Intent { act=android.intent.action.DATE_CHANGED flg=0x20200010 } to com.android.inputmethod.latin/com.android.inputmethod.dictionarypack.EventHandler
03-31 00:01:27.393 I/UsageStatsService( 1532): User[0] Flushing usage stats to disk
03-31 00:05:54.776 E/TLOC    ( 1387): [TLOCChannel]"Can't receive message due to timeout"
03-31 00:05:54.778 I/TLOC    ( 1387): [ModemComm  ]"Request succeeded for gps engine lock"
03-31 00:05:54.778 D/TLOC    ( 1387): [TLOCChannel] "Going to receive message for TLOCD"
03-31 00:05:54.778 D/TLOC    ( 1387): [TLOCChannel] "wait for message for user TLOCD"
03-31 00:05:55.777 E/TLOC    ( 1387): [TLOCChannel]"Can't receive message due to timeout"
03-31 00:05:55.777 E/TLOC    ( 1387): [TLOCDaemon ]"Couldn't receive command response"
03-31 00:05:55.777 I/TLOC    ( 1387): [TLOCDaemon ]"timeout passed - start periodic warm-up"
03-31 00:05:55.779 I/TLOC    ( 1387): [ModemComm  ]"Start a session successfully"
03-31 00:05:55.779 D/TLOC    ( 1387): [TLOCDaemon ]"The command finished successfully"
03-31 00:05:55.779 D/TLOC    ( 1387): [TLOCDaemon ]"waiting for command"
03-31 00:05:55.779 D/TLOC    ( 1387): [TLOCChannel] "Going to receive message for TLOCD"
03-31 00:05:55.779 D/TLOC    ( 1387): [TLOCChannel] "wait for message for user TLOCD"
03-31 00:06:15.779 E/TLOC    ( 1387): [TLOCChannel]"Can't receive message due to timeout"
03-31 00:06:15.780 I/TLOC    ( 1387): [TLOCDaemon ]"timeout passed with no location fix - close the session"
03-31 00:06:15.781 I/TLOC    ( 1387): [ModemComm  ]"Stopped the session successfully"
03-31 00:06:15.781 I/TLOC    ( 1387): [Modem      ]"Received event indication of position report with status USER_END"
03-31 00:06:15.781 D/TLOC    ( 1387): [TLOCDaemon ]"The command finished successfully"
03-31 00:06:15.781 D/TLOC    ( 1387): [TLOCDaemon ]"waiting for command"
03-31 00:06:15.781 D/TLOC    ( 1387): [TLOCChannel] "Going to receive message for TLOCD"
03-31 00:06:15.781 D/TLOC    ( 1387): [TLOCChannel] "wait for message for user TLOCD"
--------- beginning of crash
03-31 00:14:01.638 F/libc    ( 7911): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xb4000071254bbd in tid 8132 (Thread Pool Wor), pid 7911 (.BOSHIAC.agvapp)
03-31 00:14:01.707 F/DEBUG   ( 1487): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-31 00:14:01.707 F/DEBUG   ( 1487): Build fingerprint: 'Q115M/Q115M/Q115M:11/RKQ1.210907.001/eng.shubin.20220516.215652:user/test-keys'
03-31 00:14:01.707 F/DEBUG   ( 1487): Revision: '0'
03-31 00:14:01.707 F/DEBUG   ( 1487): ABI: 'arm64'
03-31 00:14:01.707 F/DEBUG   ( 1487): Timestamp: 2023-03-31 00:14:01+0800
03-31 00:14:01.707 F/DEBUG   ( 1487): pid: 7911, tid: 8132, name: Thread Pool Wor  >>> com.BOSHIAC.agvapp <<<
03-31 00:14:01.707 F/DEBUG   ( 1487): uid: 10195
03-31 00:14:01.707 F/DEBUG   ( 1487): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xb4000071254bbd
03-31 00:14:01.707 F/DEBUG   ( 1487):     x0  0000000000000012  x1  0000006f305df608  x2  0000000000000012  x3  0000006f30002020
03-31 00:14:01.707 F/DEBUG   ( 1487):     x4  0000000000000010  x5  0000000000000010  x6  fefeff6e2eff1f1f  x7  7f7f7f7f7f7f7f7f
03-31 00:14:01.707 F/DEBUG   ( 1487):     x8  0000000000000000  x9  ed762b6d22163358  x10 0000000000000002  x11 0000000000000001
03-31 00:14:01.707 F/DEBUG   ( 1487):     x12 0000007297d3a2c3  x13 0000000000000000  x14 0000007297dd1d22  x15 0000000034155555
03-31 00:14:01.707 F/DEBUG   ( 1487):     x16 0000006f3a80da30  x17 0000007297db1050  x18 0000000000000032  x19 0000000000000000
03-31 00:14:01.707 F/DEBUG   ( 1487):     x20 0000000000000000  x21 0000000000000040  x22 0000006f3a7e6648  x23 0000006f3a746545
03-31 00:14:01.707 F/DEBUG   ( 1487):     x24 0000006f3a762d57  x25 000000000000002e  x26 0000006f3a760d21  x27 0000006f3a746543
03-31 00:14:01.707 F/DEBUG   ( 1487):     x28 00b4000071254bbd  x29 0000006f305dfa90
03-31 00:14:01.707 F/DEBUG   ( 1487):     lr  0000006f3a714684  sp  0000006f305dfa30  pc  0000006f3a714694  pst 0000000080001000
03-31 00:14:01.708 F/DEBUG   ( 1487): backtrace:
03-31 00:14:01.708 F/DEBUG   ( 1487):       #00 pc 0000000000271694  /data/app/~~hRM_rd0iTvyiC9SQ4ywSVQ==/com.BOSHIAC.agvapp-o8RFjgJvaNeXA2aE_x2hHw==/lib/arm64/libmonosgen-2.0.so (mono_dump_mem+144)
03-31 00:14:03.032 W/ActivityTaskManager( 1532):   Force finishing activity com.BOSHIAC.agvapp/crc64e731f8ab2063fb12.MainActivity
03-31 00:14:03.032 I/DropBoxManagerService( 1532): add tag=data_app_native_crash isTagEnabled=true flags=0x2
03-31 00:14:03.038 I/BootReceiver( 1532): Copying /data/tombstones/tombstone_08 to DropBox (SYSTEM_TOMBSTONE)
03-31 00:14:03.041 I/DropBoxManagerService( 1532): add tag=SYSTEM_TOMBSTONE isTagEnabled=true flags=0x2
03-31 00:14:03.124 I/ActivityManager( 1532): Process com.BOSHIAC.agvapp (pid 7911) has died: fg  TOP 
03-31 00:14:03.124 I/WindowManager( 1532): WIN DEATH: Window{672110d u0 com.BOSHIAC.agvapp/crc64e731f8ab2063fb12.MainActivity}
03-31 00:14:03.147 W/ActivityManager( 1532): setHasOverlayUi called on unknown pid: 7911
03-31 00:14:06.186 E/TaskPersister( 1532): File error accessing recents directory (directory doesn't exist?).
03-31 00:20:48.575 E/KernelCpuSpeedReader( 1532): Failed to read cpu-freq: /sys/devices/system/cpu/cpu6/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)
03-31 00:20:48.575 E/KernelCpuSpeedReader( 1532): Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)
03-31 00:21:06.262 W/EntropyMixer( 1532): Failed to add HW RNG output to entropy pool
03-31 00:21:06.262 W/EntropyMixer( 1532): java.io.FileNotFoundException: /dev/hw_random: open failed: EACCES (Permission denied)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at libcore.io.IoBridge.open(IoBridge.java:492)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at java.io.FileInputStream.<init>(FileInputStream.java:160)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at java.io.FileInputStream.<init>(FileInputStream.java:115)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at com.android.server.RandomBlock.fromFile(RandomBlock.java:45)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at com.android.server.EntropyMixer.addHwRandomEntropy(EntropyMixer.java:205)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at com.android.server.EntropyMixer.access$000(EntropyMixer.java:59)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at com.android.server.EntropyMixer$1.handleMessage(EntropyMixer.java:83)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at android.os.Looper.loop(Looper.java:223)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at android.os.HandlerThread.run(HandlerThread.java:67)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at com.android.server.ServiceThread.run(ServiceThread.java:44)
03-31 00:21:06.262 W/EntropyMixer( 1532): Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at libcore.io.Linux.open(Native Method)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	at libcore.io.IoBridge.open(IoBridge.java:478)
03-31 00:21:06.262 W/EntropyMixer( 1532): 	... 10 more
03-31 00:21:06.262 I/EntropyMixer( 1532): Writing entropy...
03-31 00:21:27.538 I/UsageStatsService( 1532): User[0] Flushing usage stats to disk
03-31 00:36:15.783 E/TLOC    ( 1387): [TLOCChannel]"Can't receive message due to timeout"
03-31 00:36:15.787 I/TLOC    ( 1387): [ModemComm  ]"Request succeeded for gps engine lock"
03-31 00:36:15.787 D/TLOC    ( 1387): [TLOCChannel] "Going to receive message for TLOCD"
03-31 00:36:15.787 D/TLOC    ( 1387): [TLOCChannel] "wait for message for user TLOCD"
03-31 00:36:16.785 E/TLOC    ( 1387): [TLOCChannel]"Can't receive message due to timeout"
03-31 00:36:16.785 E/TLOC    ( 1387): [TLOCDaemon ]"Couldn't receive command response"
03-31 00:36:16.785 I/TLOC    ( 1387): [TLOCDaemon ]"timeout passed - start periodic warm-up"
03-31 00:36:16.787 I/TLOC    ( 1387): [ModemComm  ]"Start a session successfully"
03-31 00:36:16.787 D/TLOC    ( 1387): [TLOCDaemon ]"The command finished successfully"
03-31 00:36:16.787 D/TLOC    ( 1387): [TLOCDaemon ]"waiting for command"
03-31 00:36:16.787 D/TLOC    ( 1387): [TLOCChannel] "Going to receive message for TLOCD"
03-31 00:36:16.787 D/TLOC    ( 1387): [TLOCChannel] "wait for message for user TLOCD"
03-31 00:36:36.789 E/TLOC    ( 1387): [TLOCChannel]"Can't receive message due to timeout"
03-31 00:36:36.789 I/TLOC    ( 1387): [TLOCDaemon ]"timeout passed with no location fix - close the session"
03-31 00:36:36.790 I/TLOC    ( 1387): [Modem      ]"Received event indication of position report with status USER_END"
03-31 00:36:36.790 I/TLOC    ( 1387): [ModemComm  ]"Stopped the session successfully"
03-31 00:36:36.790 D/TLOC    ( 1387): [TLOCDaemon ]"The command finished successfully"
03-31 00:36:36.790 D/TLOC    ( 1387): [TLOCDaemon ]"waiting for command"
03-31 00:36:36.790 D/TLOC    ( 1387): [TLOCChannel] "Going to receive message for TLOCD"
03-31 00:36:36.790 D/TLOC    ( 1387): [TLOCChannel] "wait for message for user TLOCD"
03-31 00:41:27.692 I/UsageStatsService( 1532): User[0] Flushing usage stats to disk
03-31 00:50:48.576 E/KernelCpuSpeedReader( 1532): Failed to read cpu-freq: /sys/devices/system/cpu/cpu6/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)
03-31 00:50:48.576 E/KernelCpuSpeedReader( 1532): Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state: open failed: ENOENT (No such file or directory)

adb shell top

help

在这里插入图片描述

一个demo

定时刷新指定进程下的所有线程信息
先通过adb shell ps | grep 找到自己的包对应的pid
adb shell top -H -p 4924 -m 50
在这里插入图片描述

说明

Tasks: 552 total, 1 running, 510 sleeping, 0 stopped, 0 zombie
任务(进程) 系统现在共有552个进程,其中处于运行中的有1个,510个在休眠(sleep),stoped状态的有0个,zombie状态(僵尸)的有0个。
Mem: 5849960k total, 4014628k used, 1835332k free, 5756k buffers
内存状态: 物理内存总量 (5.6G) 使用中的内存总量 空闲内存总量 缓存的内存量
1TB=1024GB ,1GB=1024MB ,1MB=1024KB ,1KB=1024字节。
Swap: 2293756k total, 1039804k used, 1253952k free, 918600k cached
swap交换分区: 交换区总量 使用的交换区总量 空闲交换区总量 缓冲的交换区总量
如果出于习惯去计算可用内存数,这里有个近似的计算公式:
Mem的free + Mem的buffers + Swap的cached
按这个公式此台服务器的可用内存:1835332k + 5756k + 918600k = 2759688k(约2.6G)
800%cpu 13%user 0%nice 31%sys 756%idle 0%iow 0%irq 0%sirq 0%host
cpu状态
800%cpu – CPU总量
13%user – 用户空间占用CPU的百分比。
0%nice – 改变过优先级的进程占用CPU的百分比
31%sys – 内核空间占用CPU的百分比
756%idle – 空闲CPU百分比
0%iow – IO等待占用CPU的百分比
0%irq – 硬中断(Hardware IRQ)占用CPU的百分比
0%sirq – 软中断(Software Interrupts)占用CPU的百分比
0%host –
PID — 进程id
USER — 进程所有者
PR — 进程优先级
NI — nice值。负值表示高优先级,正值表示低优先级
VIRT — 进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES
RES — 进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATA
SHR — 共享内存大小,单位kb
S — 进程状态。D=不可中断的睡眠状态 R=运行 S=睡眠 T=跟踪/停止 Z=僵尸进程
%CPU — 上次更新到现在的CPU时间占用百分比
%MEM — 进程使用的物理内存百分比
TIME+ — 进程使用的CPU时间总计,单位1/100秒
COMMAND — 进程名称(命令名/命令行)

https://www.jianshu.com/p/68e04c27246e

adb shell dumpsys meminfo <package_name>

查看包数据信息

在这里插入图片描述
重点关注如下几个字段:
(1) Native/Dalvik 的 Heap 信息
具体在上面的第一行和第二行,它分别给出的是JNI层和Java层的内存分配情况,如果发现这个值一直增长,则代表程序可能出现了内存泄漏。

(2) Total 的 PSS 信息
这个值就是你的应用真正占据的内存大小,通过这个信息,你可以轻松判别手机中哪些程序占内存比较大了。

VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)
RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)
PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)
USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)

VSS:VSS表示一个进程可访问的全部内存地址空间的大小。这个大小包括了进程已经申请但尚未使用的内存空间。在实际中很少用这种方式来表示进程占用内存的情况,用它来表示单个进程的内存使用情况是不准确的。
RSS:表示一个进程在RAM中实际使用的空间地址大小,包括了全部共享库占用的内存,这种表示进程占用内存的情况也是不准确的。
PSS:表示一个进程在RAM中实际使用的空间地址大小,它按比例包含了共享库占用的内存。假如有3个进程使用同一个共享库,那么每个进程的PSS就包括了1/3大小的共享库内存。这种方式表示进程的内存使用情况较准确,但当只有一个进程使用共享库时,其情况和RSS一模一样。
USS:表示一个进程本身占用的内存空间大小,不包含其它任何成分,这是表示进程内存大小的最好方式!


adb bugreport

使用adb bugreport命令,导出crash文件查看详细

adb bugreport <导出的目标目录 D:\test>

导出的文件结构
在这里插入图片描述
根据日期找到对应的文件,第一眼就看到了null pointer dereference 的内容,是一个线程名PingModbus导致的

在这里插入图片描述
对应代码中找到代码,进行二次排查

同系列文章推荐

.net开发安卓入门 - 环境安装
.net开发安卓入门 - Hello world!
.net开发安卓入门 - 基本交互(Button,输入EditText,TextView,Toast)
.net开发安卓入门 - 布局与样式
.net开发安卓入门 - Activity
.net开发安卓入门 - Notification(通知)
.net开发安卓入门 - 四大基本组件
.net开发安卓入门 - Service (服务)
.net开发安卓入门 - 打包(.apk)
.net开发安卓入门 - ImageView 显示网络图片
.net开发安卓入门-文件操作与配置操作
.net开发安卓入门-Dialog
.net开发安卓入门-自动升级(配合.net6 webapi 作为服务端)
vs2022 实现无线调试安卓(Windows)
.net开发安卓从入门到放弃
.net开发安卓从入门到放弃 最后的挣扎(排查程序闪退问题记录-到目前为止仍在继续)
.net开发安卓入门 -记录两个问题处理办法

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值