Android Studio生成错误日志方法

本文详细指导如何在Android Studio中通过ADB获取并解析应用崩溃日志,包括设置USB调试、下载平台工具、运行应用直至崩溃,并使用`adb logcat`命令保存详细的错误信息到文本文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Android Studio生成错误日志方法

Use the Android Debugger to get a crash dump.

  1. On the Android device navigate to Settings > Developer options > enable USB debugging(打开开发者人员选项中的usb调试)

  2. Connect the Android device to computer with USB(用USB连接手机和电脑)

  3. Download the Android SDK Platform Tools: Android Studio > Tools> SDK Manager > Android SDK > SDK Tools > Android SDK Platform-Tools(下载 Android SDK Platform Tools)

  4. If on windows navigate to - C:\Users\[user]\AppData\Local\Android\sdk\platform-tools(在Android Studio的terminal中cd到Android SDK Platform Tools的下载目录,里面有adb.exe,可以用everything查找adb.exe)

    If on mac navigate to /Users/[user]/Library/Android/sdk/platform-tools

在这里插入图片描述

  1. Run the App and crash the app(启动APP让其崩溃)

  2. From the terminal run: ./adb logcat -v threadtime -d > /path_to_random_text_file_for_crash_dump/test.txt

path_to_random_text_file_for_crash_dump可以自定义
也可以放在当前目录adb logcat -v threadtime -d > test.txt

A more detailed error should be in the test.txt.(查看crash dump文件)

在这里插入图片描述

在github提交issue时可能test.txt过大,可以新建一个github仓库存放test.txt,然后把github仓库存放的test.txt以链接的形式放在issue中,例如

https://github.com/douzaikongcheng/log/blob/main/test.txt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值