Problem description
This exception occurs when a thread is created in an app. If the exception is not caught in the thread, the exception will be caught in RuntimeInit and the thread will be killed. Check other log entries near the specified log entries to determine the cause.
Solution
The uncaughtException occurs because the exception related with the thread started in the app is not caught. We recommend that you catch the exception in the thread and handle it. If the exception cannot be caught in the thread, specify the default UncaughtException Handler of the thread to handle it.
Sample code
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 an 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();
}