Multithreaded debugging in Android Studio

4,016 views
Skip to first unread message

Adam Vollmer

unread,
Aug 28, 2013, 11:45:31 AM8/28/13
to adt...@googlegroups.com
Has anyone else been having trouble with debugging multithreaded code in Android Studio? I seem to be able to reliably hit breakpoints on my main thread, but on no other thread. This means that I completely miss points that I've set the breakpoint for, making debugging a very, very frustrating experience.

Streets Of Boston

unread,
Aug 29, 2013, 5:06:01 PM8/29/13
to adt...@googlegroups.com
Same here, but only occasionally.

What irks me more is that putting breakpoints on multiple threads (or just background threads) cause the app to hang (ANR error). After a break-point has been hit, continuing may cause the debugger to block the app from running and the debugger will be in a 'waiting for debugging command to finish' state forever. The only way out of it is to kill the app (closing Android Studio won't help; I guess the debug-socket on the app remains open and blocked) and start all over.

Michael Prentice

unread,
May 25, 2014, 3:58:37 PM5/25/14
to adt...@googlegroups.com
I have been trying to debug an AsyncTask in a Service today and I can't seem to get it to hit any of my breakpoints at all. It is very frustrating.

Am I doing something wrong or does this just not yet work in Android Studio (0.5.8)?

Michael Prentice
GDG Space Coast

Jonathan Steele

unread,
May 26, 2014, 6:35:48 PM5/26/14
to adt...@googlegroups.com
AsyncTask is for a background parsing then display it to UI in a short period of times.
Service is for long running operation.

Anders Aagaard

unread,
May 27, 2014, 5:11:12 AM5/27/14
to adt...@googlegroups.com
Services can exist in the same thread as your main app, even if you have a service you would offload background tasks to another thread than the service thread..

Michael Prentice

unread,
May 27, 2014, 11:05:42 AM5/27/14
to adt...@googlegroups.com
OK, I need my service to continuously run in the background and not be bound to the life cycle of the main application. The service needs to keep data in an ongoing notification up to date. I have this working fine and the two communicate via Messages over registered Handlers (handler registration done in main app's bind/unbind).

Now I need my service to send and receive an HTTP request at some interval and I don't want it to block waiting for the request (it may need to accept Messages from the main app during this time). So I am using an AsyncTask which sends the request and receives it (in doInBackground), and then puts the data in a Bundle and sends it on the Messenger (in onPostExecute) and uses the data to update the ongoing notification.

So yes, I am using AsyncTask for background data retrieval and processing. I am also using an Service which starts at boot time, refreshes the data hourly, and keeps the ongoing notification alive. I verify that this Service is running/updating every hour via AlarmManager.

I suppose that I should put the data into a ContentProvider every hour. But I still need the Service to keep the ongoing notification active and updated.

I'm not sure that any of this will help at all with the debugger hitting breakpoints in my AsyncTask though.

Siva Velusamy

unread,
May 27, 2014, 11:49:31 AM5/27/14
to adt...@googlegroups.com
If you have a reproducible test case that you can share, then please file a bug with that test case. As far as I know, there are no known issues in this area. It is hard to say more without looking at your app.

One issue that has caused some confusion is if your application has multiple processes. The debugger attaches to only one of the processes.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages