Google 开发者控制台显示我的应用在过去一个月中收到了两个相同的错误,但是这个 RuntimeException
没有指定错误源自的类或文件。我看不到任何具体的东西。以下是两种不同设备的错误:
三星 Galaxy S8 Active (cruiserlteatt),4096MB RAM,Android 7.0 报告 1,共 2 个
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3045)
at android.app.ActivityThread.handleRelaunchActivity
(ActivityThread.java:4978)
at android.app.ActivityThread.-wrap21 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1648)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6781)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
三星 Galaxy S7 (heroqltespr),4096MB RAM,Android 7.0 报告第 2 个,共 2 个
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:3008)
at android.app.ActivityThread.handleRelaunchActivity
(ActivityThread.java:4974)
at android.app.ActivityThread.-wrap21 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1656)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6688)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)
是什么导致了这个错误?这只是它发生的两次,并且提供的日志没有像我能够解决的其他错误那样显示 java 类或 xml 文件。
如果有人能帮我解决这个问题,将不胜感激, 非常感谢。
最佳答案
根据the source code ,这里是 ActivityThread.performLaunchActivity
中两个地方抛出了 RuntimeException
。它们是:
} catch (Exception e) {
if (!mInstrumentation.onException(activity, e)) {
throw new RuntimeException(
"Unable to instantiate activity " + component
+ ": " + e.toString(), e);
}
}
和
} catch (Exception e) {
if (!mInstrumentation.onException(activity, e)) {
throw new RuntimeException(
"Unable to start activity " + component
+ ": " + e.toString(), e);
}
}
如你所见:
- 它们都为
RuntimeException
提供了一条消息,其中包括来自原始异常的异常消息。 - 它们都将原始异常 (
e
) 传递给RuntimeException
构造函数,以便正确链接。
如果没有因果异常消息(至少)和因果异常堆栈跟踪,或者您的完整应用源代码,几乎不可能诊断您的问题。
您需要弄清楚如何让 Google Developer Console 为您提供丢失的信息,或者让 logcat 记录它们。 如果缺少这些信息,我们将无法为您提供帮助。
除此之外,我可以建议您尝试诊断此类问题的最佳方法是查看 Android 源代码。 (这在这里不是很有帮助......但如果您缺少诊断信息,它会很有帮助。)
关于java - 如何解决这个 java.lang.RuntimeException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47238636/