【问题标题】:How to resolve this java.lang.RuntimeException?如何解决这个 java.lang.RuntimeException?
【发布时间】:2018-04-24 14:50:51
【问题描述】:

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 文件。

如果有人能帮我解决这个问题,将不胜感激, 非常感谢。

【问题讨论】:

  • 大多数情况下,您会在日志中发现另一个异常。请不要省略那个。
  • @greenapps 什么都没有遗漏,我已经提供了所有内容,并在我的帖子中说明了这一点。
  • '这个RuntimeException 没有指定错误源自的类或文件'。是的,它确实。类是RuntimeException,文件是ActivityThread.java,行号是2984。
  • 您解决过这个问题吗?我偶尔也会在我的一个应用程序中看到它。但我似乎无法在我的模拟器或设备上重现该问题
  • 嗨@4u53r 您是否设法解决了这个问题,或者至少知道问题出在哪里?我也有同样的情况:|

标签: java android runtimeexception


【解决方案1】:

根据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 源代码。 (这在这里不是很有帮助......但如果您缺少诊断信息,它会很有帮助。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 2014-11-10
    • 2014-10-07
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多