Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve this java.lang.RuntimeException?

The Google Developer Console shows that my app has received two of the same errors in the past month, but this RuntimeException doesn't specify a class or file for which the error stems from. There's nothing specific that I can see. Below are the error for two different devices:

Samsung Galaxy S8 Active (cruiserlteatt), 4096MB RAM, Android 7.0 Report 1 of 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)

Samsung Galaxy S7 (heroqltespr), 4096MB RAM, Android 7.0 Report 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)

What could it be causing this error? These are the only two times it happened, and the log provided doesn't show a java class or xml file like other errors I am able to resolve.

Would greatly appreciate it if someone could help me resolve this, many thanks.

like image 826
4u53r Avatar asked Nov 11 '17 13:11

4u53r


1 Answers

According to the source code, here are two places in ActivityThread.performLaunchActivity where RuntimeException is thrown. They are:

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

and

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

As you can see:

  • They both provide a message for the RuntimeException that includes the exception message from the original exception.
  • They both pass the original exception (e) to the RuntimeException constructor so that it is properly chained.

Without the causal exception message (at least) and the causal exception stacktrace, OR your complete app source code, it is going to be next to impossible to diagnose your problem.

You need to figure out how to get the Google Developer Console to give you the missing info, or get logcat to log them. We can't help you without that missing info.

Apart from that, I can advise you that the best way to try to diagnose problems like this is to look at the Android source code. (It is not very helpful here ... but it would be if you had the missing diagnostic information.)

like image 59
Stephen C Avatar answered Nov 01 '22 14:11

Stephen C