mcc,
@mcc@mastodon.social avatar

Say I am developing an Android app. I have the source, I built it myself.

It has a problem where occasionally Android pops up a box saying "[App] isn't responding. * Close app * Wait".

I would like to know what the app is doing when this occurs— stack traces, 1 second of profiling, something.

I expect if I tap "Close app", it should drop something useful in the logcat. I've nabbed a logcat within 120 seconds however and see nothing involving "crash" or "ANR".

What should I do to debug this?

mcc,
@mcc@mastodon.social avatar

Unfortunately I cannot get this to happen on demand, so running with adb connected is not an option. I can only make it happen by using the app regularly for a couple days, if I do this I get the hang once every 12 to 48 hours. So I need something I can do in pure-mobile mode, something like the "Stackshots" from iOS would be perfect.

It seems like since I built the app myself, I ought to have more options than if this were just something I'd downloaded…!

swiftcoder,
@swiftcoder@mastodon.social avatar

@mcc The most common approach would be to hookup the app to Firebase Crashlytics, and then your ANR traces will end up in the cloud.

I think your odds of getting ADB connected and logcat running before the ANR falls out of the buffer are slim-to-none. Although connecting ADB over wifi and just having your PC continually spool logcat to a file the whole day might work?

mcc,
@mcc@mastodon.social avatar

@swiftcoder Everything would be perfect if I could just instruct it to copy my ANR traces to a known location on /sdcard! :( I wonder, if Firebase can make that work, whether I could write my own apk to make that work.

swiftcoder,
@swiftcoder@mastodon.social avatar

@mcc Have you explored the /data/anr/ directory? In theory a copy should be stored there for each ANR (unclear what the timeline for eviction is, however)

aaryte,
@aaryte@mastodon.online avatar

@swiftcoder @mcc

What Tristam said is also what the official docs say about debugging these Application Not Responding" errors.

https://source.android.com/docs/core/tests/debug/read-bug-reports#anrs-deadlocks

Maybe start by connecting over adb and running something like
adb shell ls /data/anr
to list what's there.

mcc,
@mcc@mastodon.social avatar

@aaryte I was able to list the files in that directory, but shell cat or pull gave me denied permissions when I tried to read them. I was eventually able to get them off with adb bugreport however.

JosJuice,
@JosJuice@mastodon.social avatar

@mcc Would it be possible to connect over adb once you reproduce the issue? Then you could attach a debugger to the running app, pause the app, and look at what each thread is doing. If you can't use adb at all, I'm afraid it's going to be harder

mcc,
@mcc@mastodon.social avatar

@JosJuice Often it un-wedges itself if I wait 30-60 seconds, so no, my attempts at this have not been successful. It doesn't help that this happens at true random, so sometimes I'm not even at home when it happens.

JosJuice,
@JosJuice@mastodon.social avatar

@mcc You may want to try the "Take bug report" option: https://developer.android.com/studio/debug/bug-report

I haven't tried this for an ANR before, so I'm not sure how well it works exactly

mcc,
@mcc@mastodon.social avatar

@JosJuice Wouldn't I need to run in that mode for hours to get the log I need, though? Hm. I guess I could turn it on once the event begins, but the chances of the app being oomkilled while I'm in Settings are high…

JosJuice,
@JosJuice@mastodon.social avatar

@mcc It's not a mode. You press it, and it captures a kind of snapshot of the current state. You do have to go into the settings app to trigger it, but in my experience, modern devices have enough RAM that opening the settings app won't cause a game to have its process killed due to OOM

mcc,
@mcc@mastodon.social avatar

@JosJuice Thanks. I'll consider it, although at present I am using a $35 phone I got at walmart while my real phone is in repair, so… I dunno if it can be described as a "modern device".

JosJuice,
@JosJuice@mastodon.social avatar

@mcc Ah

mcc,
@mcc@mastodon.social avatar

Okay so @swiftcoder has just informed me about Android's /data/anr directory, which sounds like exactly what I'm looking for, and does in fact contain files matching known ANR events. Unfortunately, this phone denies ADB permissions to read those files!

…BUT, adb bugreport does copy, in the FS/data/anr subdirectory, the files, so I now have what I need. Thanks y'all

swiftcoder,
@swiftcoder@mastodon.social avatar

@mcc hah. Almost all my Android experience is from the OS development side of things, so our devices tend to all be rooted

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • cubers
  • InstantRegret
  • cisconetworking
  • Youngstown
  • vwfavf
  • slotface
  • Durango
  • rosin
  • everett
  • kavyap
  • thenastyranch
  • mdbf
  • megavids
  • khanakhh
  • modclub
  • tester
  • ethstaker
  • osvaldo12
  • GTA5RPClips
  • ngwrru68w68
  • Leos
  • anitta
  • tacticalgear
  • normalnudes
  • provamag3
  • JUstTest
  • All magazines