I need to debug an android application that is already installed on a phone. I am able to start the application in debug mode but I can't connect to the process using JDWP. I have try two different ways that both fail. (see following sections)
Command line attempt
1- Start the application
[...]sdk\platform-tools>adb -d shell am start -D -n "package/package.SomeActivity"
The application starts and a alert display "/!\ Waiting for debugger".
2- Open a JDWP port
[...]sdk\platform-tools>adb forward tcp:8000 jdwp:7602
3- Attempt to connect using 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.
IntelliJ attempt
I have configure my local project to start the default Activity and uncheck the "Deploy application".
I also get the application started with the same alert but unfortunately the IDE doesn't connect to the remote process.
Target device: 42f7cc14e2acbfab
Launching application: ********/********.SomeActivity.
DEVICE SHELL COMMAND: am start -D -n "********/********.SomeActivity"
Starting: Intent { cmp=********/********.SomeActivity }
Waiting for process: ********