java.lang.NullPointerException

Appcelerator JIRA | Mostafizur Rahman | 3 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

    h5. Problem Description Exception is thrown when passing objects with null/undefined values for expected keys values on Android. Ti.map.TiUIMapView passes this null value to TiConvert.toDouble which causes then throws a NullPointerException. Here is an example piece of code when setting a map region. This works fine on iOS: {code} function setup(event) { $.map.region = { latitude: 36, longitude: -78, latitudeDelta: null, longitudeDelta: null }; } {code} Here is the exception on Android: {code} [ERROR] : TiApplication: (main) [1830,1830] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.2.0,2013/12/20 10:57,d9182d6 [ERROR] : TiApplication: java.lang.NullPointerException [ERROR] : TiApplication: at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:527) [ERROR] : TiApplication: at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:540) [ERROR] : TiApplication: at ti.map.TiUIMapView.updateCamera(TiUIMapView.java:247) [ERROR] : TiApplication: at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:171) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:329) [ERROR] : TiApplication: at ti.map.ViewProxy.handleMessage(ViewProxy.java:150) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:158) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5789) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:525) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) {code} This the kroll bridge should either ignore null/undefined values or have each have maps module defensively check for null values. I've attached a project showcases the error.

    Appcelerator JIRA | 3 years ago | Mostafizur Rahman
    java.lang.NullPointerException
  2. 0

    h5. Problem Description Exception is thrown when passing objects with null/undefined values for expected keys values on Android. Ti.map.TiUIMapView passes this null value to TiConvert.toDouble which causes then throws a NullPointerException. Here is an example piece of code when setting a map region. This works fine on iOS: {code} function setup(event) { $.map.region = { latitude: 36, longitude: -78, latitudeDelta: null, longitudeDelta: null }; } {code} Here is the exception on Android: {code} [ERROR] : TiApplication: (main) [1830,1830] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.2.0,2013/12/20 10:57,d9182d6 [ERROR] : TiApplication: java.lang.NullPointerException [ERROR] : TiApplication: at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:527) [ERROR] : TiApplication: at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:540) [ERROR] : TiApplication: at ti.map.TiUIMapView.updateCamera(TiUIMapView.java:247) [ERROR] : TiApplication: at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:171) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:329) [ERROR] : TiApplication: at ti.map.ViewProxy.handleMessage(ViewProxy.java:150) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:158) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5789) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:525) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) {code} This the kroll bridge should either ignore null/undefined values or have each have maps module defensively check for null values. I've attached a project showcases the error.

    Appcelerator JIRA | 3 years ago | Mostafizur Rahman
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.appcelerator.titanium.util.TiConvert.toDouble()
    2. org.appcelerator.titanium
      TiConvert.toDouble
      1. org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:527)
      2. org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:540)
      2 frames
    3. ti.map
      TiUIMapView.propertyChanged
      1. ti.map.TiUIMapView.updateCamera(TiUIMapView.java:247)
      2. ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:171)
      2 frames
    4. org.appcelerator.kroll
      KrollProxy.handleMessage
      1. org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
      2. org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059)
      2 frames
    5. org.appcelerator.titanium
      TiViewProxy.handleMessage
      1. org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:329)
      1 frame
    6. ti.map
      ViewProxy.handleMessage
      1. ti.map.ViewProxy.handleMessage(ViewProxy.java:150)
      1 frame
    7. Android Platform
      ActivityThread.main
      1. android.os.Handler.dispatchMessage(Handler.java:95)
      2. android.os.Looper.loop(Looper.java:158)
      3. android.app.ActivityThread.main(ActivityThread.java:5789)
      3 frames
    8. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:525)
      2 frames
    9. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
      2 frames
    10. Android Platform
      NativeStart.main
      1. dalvik.system.NativeStart.main(Native Method)
      1 frame