I\'m trying to hook up jdb on my computer to a process (any process really) on my Android device, but it doesn\'t work at all.
So the commands I used are straight of
You can try entering this command:
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=3456
Theoretically, you should get the following output:
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
>
However, I got the following:
java.io.IOException: handshake failed - connection prematurally closed
at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:136)
at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90)
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)
Does anyone know why this is happening?
Ok... The above problem has been resolved. This is due to a conflict between adb calls. There should only be 1 adb instance running at any point in time. This will occur when jdb tries to connect while adb is already running in your program. jdb will never be able to attach successfully in this state.
The TLDR version would be to just key in the command at the top of this answer and you will get the expected output.