My application gives an anr while debugging on my Samsung Galaxy Tab. The device is viewable in DDMS in Eclipse, and I can browse the sdcard with the DDMS file explorer. But I cannot browse into the data directory (when I click the drop down arrow next to this directory, it appears the directory is open). Any tips how I can obtain the file?
A good way to try to detect the problem is by fetching the file /data/anr/traces. txt which is generated after a ANR happens on a device (beware that it is overridden after another ANR happens). That offers you a overview of what each thread was doing at the time of the ANR.
Using traces file:After ANR is recreated pull the traces file via adb pull /data/anr/traces. txt command. In the above example the main thread is held by SampleHandlerThread and SampleHandlerThread is held by the main thread causing a Deadlock.
ANR data is available in Play Console only. You'll see all ANRs collected from Android devices whose users have opted in to automatically share usage and diagnostics data. Data is available for the previous two months. For more information about how Android users opt in to share data, go to the Accounts Help Center.
How to prevent an ANR? Stop doing heavy tasks on the main thread. Instead use worker threads such as IntentService, AsyncTask Handler, or another Thread simply.
You can fetch the file using the following command:
adb pull /data/anr/traces.txt
Hope this helps, Francisco.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With