Hey! Is there any way to simulate an ANR that actu...
# android
r
Hey! Is there any way to simulate an ANR that actually gets reported as ANR in
ApplicationExitInfo
(https://developer.android.com/reference/android/app/ApplicationExitInfo#REASON_ANR)? I wanted to test some ANR reporting but I’m not able to actually reproduce an ANR. I’ve attempted (all inside an on click): •
Thread.sleep(60000)
while (true) {}
• Deadlocking with a mutex All of these crash the app but the exit info reason is always something else. There’s a couple of similar threads on this channel but they didn’t really help me. Thanks!
not kotlin but kotlin colored 1
sorry 1
j
No. The best you can do is profile your app and check where your cpu usage is high for a long time.... For instance you may be doing a bunch of IO ( instantiate or read shared preferences or dbs) in the application.onCreate method...
r
I don't want to fix an ANR, I want to force one to test reporting of ANRs. It just turns out that it's harder to actually do one on purpose than I was expecting 😅
j
A Thread.sleep(10000) in the main thread should be enough...
r
I've tried that but the ApplicationExitInfo API in Android does not report it as such.