android.os.Debug类

本文介绍了如何使用Android OS Debug类进行应用性能调试与跟踪,包括导入相关包、开启与关闭跟踪、以及如何在SD卡上查看跟踪结果。通过使用traceview工具,开发者可以深入分析应用的运行状态。

android.os.Debug类

使用起来比较简单,我们先导入 import android.os.Debug这个包。

在需要开始跟踪的地方加入 Debug.startMethodTracing(“/sdcard/debug”);

最终在停止调试的地方加入 Debug.stopMethodTracing();

最终在sdcard上生成的debug文件我们可以用sdk/tools中的traceview来查看运行的结果。

10-02 08:51:02.472 4686 4686 F DEBUG : at void android.app.ActivityThread$3.onTransactionError(int, int, int, int) (ActivityThread.java:8696) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Binder.transactionCallback(int, int, int, int) (Binder.java:719) 10-02 08:51:02.472 4686 4686 F DEBUG : at boolean android.os.BinderProxy.transactNative(int, android.os.Parcel, android.os.Parcel, int) (BinderProxy.java:-2) 10-02 08:51:02.472 4686 4686 F DEBUG : at boolean android.os.BinderProxy.transact(int, android.os.Parcel, android.os.Parcel, int) (BinderProxy.java:685) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.wm.shell.shared.IShellTransitions$Stub$Proxy.unregisterRemoteTaskListener(com.android.wm.shell.shared.IOplusTaskListener) (IShellTransitions.java:19) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.quickstep.proxy.OplusSystemUiProxyImpl.removeTaskListener(com.android.wm.shell.shared.IOplusTaskListener) (OplusSystemUiProxyImpl.kt:40) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.oplus.quickstep.taskviewremoteanim.TaskStateHelper.unregisterTaskListener(android.content.Context) (TaskStateHelper.kt:19) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.oplus.quickstep.taskviewremoteanim.TaskStateHelper.release(android.content.Context) (TaskStateHelper.kt:25) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.quickstep.SystemUiProxy.clearProxy() (SystemUiProxy.java:10) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.launcher.guide.gdq.run() (R8$$SyntheticClass:28) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:1027) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:108) 10-02 08:51:02.472 4686 4686 F DEBUG : at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:298) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Looper.loop() (Looper.java:408) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.launcher.monitor.exception.MainThreadExceptionMonitor.startWatching$lambda$2(com.android.launcher.monitor.exception.MainThreadExceptionMonitor) (MainThreadExceptionMonitor.kt:15) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.launcher.monitor.exception.MainThreadExceptionMonitor.gda(com.android.launcher.monitor.exception.MainThreadExceptionMonitor) (MainThreadExceptionMonitor.kt:1) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.launcher.monitor.exception.gda.run() (R8$$SyntheticClass:46) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:1027) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:108) 10-02 08:51:02.472 4686 4686 F DEBUG : at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:298) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.os.Looper.loop() (Looper.java:408) 10-02 08:51:02.472 4686 4686 F DEBUG : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:9952) 10-02 08:51:02.472 4686 4686 F DEBUG : at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:613) 10-02 08:51:02.472 4686 4686 F DEBUG : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:1074) 10-02 08:51:02.472 4686 4686 F DEBUG : Caused by: android.os.DeadSystemException: 加上这部分堆栈信息能确定是binder超限吗
最新发布
10-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值