While trying to install a custom exception handler to catch uncaught exceptions (crashes), I ended up writing

CustomExceptionHandler handler = new CustomExceptionHandler(Thread.currentThread().getUncaughtExceptionHandler());
Thread.setDefaultUncaughtExceptionHandler(handler);

instead of

Thread.UncaughtExceptionHandler existingHandler = Thread.getDefaultUncaughtExceptionHandler();
CustomExceptionHandler handler = new CustomExceptionHandler(existingHandler);
Thread.setDefaultUncaughtExceptionHandler(handler);

The difference looks minor but it broke the exception handler and converted every crash into a cryptic ANR!

0 libc.so syscall 
1 libart.so art::ConditionVariable::WaitHoldingLocks(art::Thread*) 
2 libart.so art::ThreadList::WaitForOtherNonDaemonThreadsToExit(bool) 
3 libart.so art::JII::DestroyJavaVM(_JavaVM*) 
4 libandroid_runtime.so android::AndroidRuntime::start(char const*, android::Vector const&, bool) 
5 app_process64 main 
6 libc.so __libc_init

 

Very occasionally, I got a more useful error that didn’t look related but it was.

java.lang.StackOverflowError:
      at net.ashishb.androidmusicplayer.util.CustomExceptionHandler.uncaughtException (CustomExceptionHandler.java:20)
      at java.lang.ThreadGroup.uncaughtException (ThreadGroup.java:1068)
      at java.lang.ThreadGroup.uncaughtException (ThreadGroup.java:1063)
      at net.ashishb.androidmusicplayer.util.CustomExceptionHandler.uncaughtException (CustomExceptionHandler.java:22)
      at org.chromium.base.JavaExceptionReporter.uncaughtException (chromium-Monochrome.aab-stable-484407323:6)
      at java.lang.ThreadGroup.uncaughtException (ThreadGroup.java:1068)
      at java.lang.ThreadGroup.uncaughtException (ThreadGroup.java:1063)
      at net.ashishb.androidmusicplayer.util.CustomExceptionHandler.uncaughtException (CustomExceptionHandler.java:22)
      at org.chromium.base.JavaExceptionReporter.uncaughtException (chromium-Monochrome.aab-stable-484407323:6)
      at java.lang.ThreadGroup.uncaughtException (ThreadGroup.java:1068)
      at java.lang.ThreadGroup.uncaughtException (ThreadGroup.java:1063)
      at net.ashishb.androidmusicplayer.util.CustomExceptionHandler.uncaughtException (CustomExceptionHandler.java:22)
      at org.chromium.base.JavaExceptionReporter.uncaughtException (chromium-Monochrome.aab-stable-484407323:6)