[关闭]
@act262 2017-08-05T12:50:41.000000Z 字数 608 阅读 1552

adb shell am 命令之debug技巧

adb_shell


我们一般的调试方式都是先在某个地方打上断点,然后在运行中用ASAttach debugger to Android process进行调试的,这种方式不适合在启动app的地方断点调试,如果需要在启动的地方调试则需要Run Debug app,然而这种方式一般都是比较慢的,尤其是大项目,因为这里包含了编译运行等工作。

可以使用am的set-debug-app调试命令来操作

  1. # 开启调试模式
  2. am set-debug-app: set application <PACKAGE> to debug. Options are:
  3. -w: wait for debugger when application starts
  4. --persistent: retain this value
  5. # 清除调试模式
  6. am clear-debug-app: clear the previously set-debug-app.

-w 启动时等待Debugger Attacth
--persistent 每次启动都开启调试模式,没有这个标志则表示一次性的

开启调试某个app

  1. adb shell am set-debug-app -w com.micro.demo

运行上面命令后,app启动,并弹出Waiting For Debugger的弹窗提示,
此时打开AS的Attach debugger to Android process即可,此时我们就可以方便在app启动时的断点调试了。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注