com_android_internal_os_RuntimeInit_UncaughtHandler_uncaughtException

问题分析

此类异常发生在应用创建了线程,如果线程因为异常未捕获而退出,在RuntimeInit中会捕获此类异常并杀死进程。具体异常的原因需要看日志附近其他log确定触发异常信息。

解决方案

因为应用开启的线程抛出了异常未被捕获而导致抛出uncaughtException,建议在线程内捕获异常并做处理,如果无法在线程内捕获异常,设置线程默认的UncaughtException Handler来处理。

代码示例

    public static void main(String[] args) {
      UncaughtExceptionHandler eh=new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread t, Throwable e) {
              System.out.println("uncaught Caught " + e);
        }
      };
      Thread thread=new Thread(){
        @Override
        public void run(){
          try {
            // do something and happen a exception
            throw new IOException("e");
          } catch (IOException e) {
            System.out.println("catching IOException:");
            e.printStackTrace();
          }
          // code may cause some other exception, we could catch these, or use setDefaultUncaughtExceptionHandler
          System.out.println(1/0);
        }
      };
      thread.setDefaultUncaughtExceptionHandler(eh);
      thread.start();
    }

参考文献