Search code examples
androidgoogle-chrome-devtoolsv8stethoj2v8

How to debug J2V8 in Android with chrome developer tools?


A similar question has been asked before, but had no traction. Clearly, it is possible but it is by no means clear how to do it in our own non-tabris Android app.

The best documentation we have on the matter is this commit, but I tried V8.setFlags("--expose-debug-as=Debug"); as well as V8.setFlags("--expose-debug-as=" + DebugHandler.DEBUG_OBJECT_NAME); but no debuggable app appeared in chrome developer tools.

I even tried in combo with enabling Stetho and in that case I was able to debug the app, but there was no javascript source to debug. I believe that I'm close but missing one small crucial nugget.


Solution

  • If the question is still relevant - I have created j2v8-debugger library.

    It allows debugging J2V8 using Chrome DevTools.

    It indeed uses Stetho lib for communication with Chrome DevTools.

    Also it's uses DebugHandler for accessing V8 debug information.

    Basic features like setting/removing breakpoints, step into, step out and step over, variables inspection, etc. are implemented.

    Hope it could be helpful.