如何解决这个java.lang.RuntimeException?

4u5*_*53r 19 java android runtimeexception

Google Developer Console显示我的应用在过去一个月内收到了两个相同的错误,但这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)
Run Code Online (Sandbox Code Playgroud)

三星Galaxy S7(heroqltespr),4096MB RAM,Android 7.0报告2 of 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)
Run Code Online (Sandbox Code Playgroud)

它可能导致此错误?这是它发生的唯一两次,并且提供的日志不显示java类或xml文件,就像我能够解决的其他错误一样.

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

Ste*_*n C 6

根据源代码,这里有两个放置ActivityThread.performLaunchActivity位置RuntimeException。他们是:

    } catch (Exception e) {
        if (!mInstrumentation.onException(activity, e)) {
            throw new RuntimeException(
                "Unable to instantiate activity " + component
                + ": " + e.toString(), e);
        }
    }
Run Code Online (Sandbox Code Playgroud)

    } catch (Exception e) {
        if (!mInstrumentation.onException(activity, e)) {
            throw new RuntimeException(
                "Unable to start activity " + component
                + ": " + e.toString(), e);
        }
    }
Run Code Online (Sandbox Code Playgroud)

如你看到的:

  • 它们都提供了一条消息,RuntimeException其中包含来自原始异常的异常消息。
  • 它们都将原始异常(e)传递给RuntimeException构造函数,以便正确链接它。

如果没有(至少)因果异常消息和因果异常堆栈跟踪,或者没有完整的应用程序源代码,就很难诊断出问题。

您需要弄清楚如何获取Google Developer Console来提供缺少的信息,或者获取logcat进行记录。 如果缺少这些信息,我们将无法为您提供帮助。

除此之外,我可以建议您诊断此类问题的最佳方法是查看Android源代码。(这里不是很有帮助...但是如果您缺少诊断信息,则可能会有用。)