我需要调试已安装在手机上的Android应用程序.我能够在调试模式下启动应用程序,但我无法使用JDWP 连接到该进程.我尝试了两种不同的方法都失败了.(见以下部分)
命令行尝试
1-启动应用程序
[...]sdk\platform-tools>adb -d shell am start -D -n "package/package.SomeActivity"
Run Code Online (Sandbox Code Playgroud)
应用程序启动并显示警告"/!\ Waiting for debugger".
2-打开JDWP端口
[...]sdk\platform-tools>adb forward tcp:8000 jdwp:7602
Run Code Online (Sandbox Code Playgroud)
3-尝试使用jdb连接
[...]sdk\platform-tools>jdb -attach 127.0.0.1:8000
java.io.IOException: shmemBase_attach failed:
at com.sun.tools.jdi.SharedMemoryTransportService.attach0(Native Method)
at com.sun.tools.jdi.SharedMemoryTransportService.attach(SharedMemoryTransportService.java:108)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SharedMemoryAttachingConnector.attach(SharedMemoryAttachingConnector.java:63)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328)
at com.sun.tools.example.debug.tty.Env.init(Env.java:63)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066)
Fatal error:
Unable to attach to target VM.
Run Code Online (Sandbox Code Playgroud)
IntelliJ尝试
我已配置我的本地项目以启动默认活动并取消选中"部署应用程序".
我也使用相同的警报启动应用程序,但不幸的是IDE没有连接到远程进程.
Target device: 42f7cc14e2acbfab
Launching application: ********/********.SomeActivity.
DEVICE SHELL COMMAND: am start -D -n "********/********.SomeActivity"
Starting: Intent { cmp=********/********.SomeActivity }
Waiting for …Run Code Online (Sandbox Code Playgroud)