Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Finishing Up

Dimitris Sotiris Tsolis
Dimitris Sotiris Tsolis
28,141 Points

Debug a widget.

Hi! Thanks for the course first of all. Very good. I have a question thought. I am searching for a way to debug my widget and it's a little confusing. Is there any reference somewhere how to debug android widgets?

Thanks anyway!

1 Answer

Michael Nock
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Nock
Android Development Techdegree Graduate 16,018 Points

I think your best would be using lots of log messages to help you debug what's going on. It's a bit of a pain to debug otherwise.

After running the widget you can try "Attach debugger to Android process" (last item in the Run menu or the icon two to the right of the debug icon). If it doesn't show up, you might have to run "adb kill-server" from a terminal (on Windows, you might need to add 'adb' to the PATH variable or run it directly from the android SDK's platform-tools folder), re-run your app, and try to attach the debugger again. The connection only lasts a short while for me before it breaks and i have to reattach it, but while it's up i can set up breakpoints and step through the code (at least until it loses the connection).