Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ffabreti/8fd551ed321d51d7f458 to your computer and use it in GitHub Desktop.
Save ffabreti/8fd551ed321d51d7f458 to your computer and use it in GitHub Desktop.
Debugging Titanium Android applications with node-inspector
Thanks to Stevo Perisic
Download the https://github.com/node-inspector/node-inspector using
$ npm install -g node-inspector
Than go to your titanium project folder and run:
$ node-inspector
after that in the same dir run:
JAVA_HOME=/usr/java/latest titanium build -f -p android -T emulator -I 7 -S HVGA --debug-host localhost:5858
in your browser open localhost:8080/debug?port=5858
and voila! You have the chrome inspector in your android titanium project!
notice:
titanium build "-I 7 -S HVGA" option tries to spawn avd named titanium_7_HVGA
@gazialankus
Copy link

Actually I just found a much easier way to do this all.

  1. Disable JavaScript minification in the Debug Configuration in Titanium Studio.
  2. Press debug in Titanium Studio.
  3. Once you see the application running in GenyMotion, look at the Titanium Studio console to find the command it was ran with (in the console, see above comment), and from there copy the debug port number (the number in adb:11421 at the very end of the command).
  4. Stop the Titanium Studio debugger with the red stop button.
  5. Visit http://127.0.0.1:8080/debug?port=11421 (with the port number that you copied)
  6. Enjoy!

It seems to remember breakpoints across runs, too. The only caveat is that you lose the ability to log with Ti.API.info() and such. But since you are debugging line by line, you won't really need that much. You could probably set Ti.API.info function to a function of your choice from the node-inspector console if you really needed that anyway.

@ffabreti
Copy link
Author

Great. Thanks, will give it a try!

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