Skip to content

Instantly share code, notes, and snippets.

@sunsheng
Forked from krazylearner/setup_jdb.md
Created January 9, 2023 09:42
Show Gist options
  • Save sunsheng/275a1696fc8a5ea7ef475ef2189114ca to your computer and use it in GitHub Desktop.
Save sunsheng/275a1696fc8a5ea7ef475ef2189114ca to your computer and use it in GitHub Desktop.
set up jdb with android

start bluestack or emulator install app on it start the app

connect adb to emulator

$ adb connect localhost:5555

get 'pid' of your app .Dont forget to run it first in emulator

$ adb shell ps

confirm the pid

$ adb jdwp

forward a local socket to PID 290 to start debugging.

$ adb forward tcp:8700 jdwp:290

This tells adb to forward a local socket on port 8700 to the app with PID 290 that’s hosting a JDWP transport.

start debugging the simple test app

$ jdb -attach localhost:8700 -sourcepath /path/to/test/app/src.

on error try this instead of above command

$ "C:\Program Files\Java\jdk1.8.0_45\bin\jdb" -sourcepath ./app/src -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8700

If all goes well, you’ll have a jdb prompt in which you can start adding breakpoints.

Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...

Using the jdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment