java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference

Appcelerator JIRA | Tim Poulsen | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Creating a separate ticket for my comments on TIMOB-18098. PR https://github.com/appcelerator/titanium_mobile/pull/6958 Our app crashes frequently when the it's woken from the background by the user tapping a push notification. We are using the http://iamyellow.net/post/40100981563/gcm-appcelerator-titanium-module GCM module. {code} 06-30 14:06:51.234: W/System.err(19120): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.titanium.proxy.IntentProxy.putExtra(IntentProxy.java:198) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203) 06-30 14:06:51.234: W/System.err(19120): at android.os.Handler.dispatchMessage(Handler.java:98) 06-30 14:06:51.234: W/System.err(19120): at android.os.Looper.loop(Looper.java:145) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) {code} If the app is open when the message arrives, it is received and handled fine. If the app is in the background, we see the above in the adb logs. I have tried with 3.5.0.GA, 3.5.1.GA, 4.0.0.GA, and a nightly I built myself (don't recall the date of that build, but post GA). Tested on both Android 5.0 and 4.2.2 devices. I have found that a simple null value check in the putExtra() method resolves this issue. {code} @Kroll.method public void putExtra(String key, Object value) { if (value == null) { return; } ... {code} https://github.com/appcelerator/titanium_mobile/pull/6958 (master) https://github.com/appcelerator/titanium_mobile/pull/6957 (3_5_X)

    Appcelerator JIRA | 2 years ago | Tim Poulsen
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
  2. 0

    Creating a separate ticket for my comments on TIMOB-18098. PR https://github.com/appcelerator/titanium_mobile/pull/6958 Our app crashes frequently when the it's woken from the background by the user tapping a push notification. We are using the http://iamyellow.net/post/40100981563/gcm-appcelerator-titanium-module GCM module. {code} 06-30 14:06:51.234: W/System.err(19120): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.titanium.proxy.IntentProxy.putExtra(IntentProxy.java:198) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203) 06-30 14:06:51.234: W/System.err(19120): at android.os.Handler.dispatchMessage(Handler.java:98) 06-30 14:06:51.234: W/System.err(19120): at android.os.Looper.loop(Looper.java:145) 06-30 14:06:51.234: W/System.err(19120): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112) {code} If the app is open when the message arrives, it is received and handled fine. If the app is in the background, we see the above in the adb logs. I have tried with 3.5.0.GA, 3.5.1.GA, 4.0.0.GA, and a nightly I built myself (don't recall the date of that build, but post GA). Tested on both Android 5.0 and 4.2.2 devices. I have found that a simple null value check in the putExtra() method resolves this issue. {code} @Kroll.method public void putExtra(String key, Object value) { if (value == null) { return; } ... {code} https://github.com/appcelerator/titanium_mobile/pull/6958 (master) https://github.com/appcelerator/titanium_mobile/pull/6957 (3_5_X)

    Appcelerator JIRA | 2 years ago | Tim Poulsen
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference

      at org.appcelerator.titanium.proxy.IntentProxy.putExtra()
    2. org.appcelerator.titanium
      IntentProxy.putExtra
      1. org.appcelerator.titanium.proxy.IntentProxy.putExtra(IntentProxy.java:198)
      1 frame
    3. org.appcelerator.kroll
      V8Runtime.handleMessage
      1. org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method)
      2. org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:177)
      3. org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:299)
      4. org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:203)
      4 frames
    4. Android Platform
      Looper.loop
      1. android.os.Handler.dispatchMessage(Handler.java:98)
      2. android.os.Looper.loop(Looper.java:145)
      2 frames
    5. org.appcelerator.kroll
      KrollRuntime$KrollRuntimeThread.run
      1. org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
      1 frame