java.lang.RuntimeException: Unable to resume activity with java.lang.IllegalArgumentException

后端 未结 2 423
半阙折子戏
半阙折子戏 2021-01-30 05:10

Recently I sometimes got this exception when MainActivity called onResume().

java.lang.RuntimeException: Unable to resume activity {com.qau4d.c35s3.androidapp/co         


        
2条回答
  •  时光取名叫无心
    2021-01-30 05:28

    There is insufficient information in your question to determine the cause of the java.lang.IllegalArgumentException, Unfortunately the android ActivityThread doesn't log the stacktrace of that exception, and the exception message appears to be empty.

    However, it looks like there is a way forward. The exception is handled by the following code in the ActivityThread::performResumeActivity method:

            } catch (Exception e) {
                if (!mInstrumentation.onException(r.activity, e)) {
                    throw new RuntimeException(
                        "Unable to resume activity "
                        + r.intent.getComponent().toShortString()
                        + ": " + e.toString(), e);
                }
            }
    

    If you register an Instrumentation class for your activity, it should be possible to use an onException method to log the stacktrace for the causal exception. Another possibility is to use Thread.setUncaughtExceptionHandler to set a handler for the thread in which the IllegalArgumentException is thrown.

    These won't solve the problem (!) but it will get you a step closer to a solution.

提交回复
热议问题