java.lang.NullPointerException

Appcelerator JIRA | Arthur Evans | 5 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

    A fatal exception occurs when selecting an annotation that has an instance of Ti.UI.View passed as the rightView parameter. - This error doesn't occur if you pass an instance of ImageView as rightView and leave leftView unset. The image view is displayed as expected. - It does occur if you specify the Ti.UI.View instance as either leftView or rightView, and set the ImageView as the other view. - It doesn't occur if you set a Ti.UI.View instance to leftView and leave rightView unset. Although in this case, the view still isn't displayed. Test case: {code} var win = Titanium.UI.createWindow({ modal : true, backgroundColor : 'white' }); // an image view... var pane = Ti.UI.createImageView({ image : 'pin2.png', width : 30, height : 30 }) // and a plain view var plain = Titanium.UI.createView({ width : 20, height : 20, backgroundColor : '#336699' }); var atlantaParams = { latitude : 33.74511, longitude : -84.38993, title : "Atlanta, GA", subtitle : 'Atlanta Braves Stadium\nfoo', pincolor : Titanium.Map.ANNOTATION_GREEN, animate : true, // leftView : pane, rightView : plain }; var atlanta = Titanium.Map.createAnnotation(atlantaParams); // CREATE MAP VIEW // var mapview = Titanium.Map.createView({ mapType : Titanium.Map.STANDARD_TYPE, region : { latitude : 33.74511, longitude : -84.38993, latitudeDelta : 0.5, longitudeDelta : 0.5 }, animate : true, regionFit : true, userLocation : true, annotations : [atlanta] }); mapview.selectAnnotation(atlanta); win.add(mapview); win.open(); {code} Stack trace: {code} E/AndroidRuntime( 1387): FATAL EXCEPTION: main E/AndroidRuntime( 1387): java.lang.NullPointerException E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiOverlayItemView.setItem(TiOverlayItemView.java:191) E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiMapView.showAnnotation(TiMapView.java:493) E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiMapView.doSelectAnnotation(TiMapView.java:727) E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiMapView.handleMessage(TiMapView.java:471) E/AndroidRuntime( 1387): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 1387): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 1387): at android.app.ActivityThread.main(ActivityThread.java:4627) E/AndroidRuntime( 1387): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 1387): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 1387): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) E/AndroidRuntime( 1387): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) E/AndroidRuntime( 1387): at dalvik.system.NativeStart.main(Native Method) {code} Given the peculiar left/right behavior, I noted that the line we crash on, TiOverlayItemView.java:191: 191 rightPane.addView(rightView.peekView().getNativeView()); Does not match the corresponding code for leftView: 167 leftPane.addView((leftView.getOrCreateView()).getNativeView()); Although otherwise the handling of these views appears to be identical. Also, I wonder if this behavior explains some of the peculiarities reported in TIMOB-5038, where the annotation is not being updated.

    Appcelerator JIRA | 5 years ago | Arthur Evans
    java.lang.NullPointerException
  2. 0

    A fatal exception occurs when selecting an annotation that has an instance of Ti.UI.View passed as the rightView parameter. - This error doesn't occur if you pass an instance of ImageView as rightView and leave leftView unset. The image view is displayed as expected. - It does occur if you specify the Ti.UI.View instance as either leftView or rightView, and set the ImageView as the other view. - It doesn't occur if you set a Ti.UI.View instance to leftView and leave rightView unset. Although in this case, the view still isn't displayed. Test case: {code} var win = Titanium.UI.createWindow({ modal : true, backgroundColor : 'white' }); // an image view... var pane = Ti.UI.createImageView({ image : 'pin2.png', width : 30, height : 30 }) // and a plain view var plain = Titanium.UI.createView({ width : 20, height : 20, backgroundColor : '#336699' }); var atlantaParams = { latitude : 33.74511, longitude : -84.38993, title : "Atlanta, GA", subtitle : 'Atlanta Braves Stadium\nfoo', pincolor : Titanium.Map.ANNOTATION_GREEN, animate : true, // leftView : pane, rightView : plain }; var atlanta = Titanium.Map.createAnnotation(atlantaParams); // CREATE MAP VIEW // var mapview = Titanium.Map.createView({ mapType : Titanium.Map.STANDARD_TYPE, region : { latitude : 33.74511, longitude : -84.38993, latitudeDelta : 0.5, longitudeDelta : 0.5 }, animate : true, regionFit : true, userLocation : true, annotations : [atlanta] }); mapview.selectAnnotation(atlanta); win.add(mapview); win.open(); {code} Stack trace: {code} E/AndroidRuntime( 1387): FATAL EXCEPTION: main E/AndroidRuntime( 1387): java.lang.NullPointerException E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiOverlayItemView.setItem(TiOverlayItemView.java:191) E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiMapView.showAnnotation(TiMapView.java:493) E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiMapView.doSelectAnnotation(TiMapView.java:727) E/AndroidRuntime( 1387): at ti.modules.titanium.map.TiMapView.handleMessage(TiMapView.java:471) E/AndroidRuntime( 1387): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 1387): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 1387): at android.app.ActivityThread.main(ActivityThread.java:4627) E/AndroidRuntime( 1387): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 1387): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 1387): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) E/AndroidRuntime( 1387): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) E/AndroidRuntime( 1387): at dalvik.system.NativeStart.main(Native Method) {code} Given the peculiar left/right behavior, I noted that the line we crash on, TiOverlayItemView.java:191: 191 rightPane.addView(rightView.peekView().getNativeView()); Does not match the corresponding code for leftView: 167 leftPane.addView((leftView.getOrCreateView()).getNativeView()); Although otherwise the handling of these views appears to be identical. Also, I wonder if this behavior explains some of the peculiarities reported in TIMOB-5038, where the annotation is not being updated.

    Appcelerator JIRA | 5 years ago | Arthur Evans
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at ti.modules.titanium.map.TiOverlayItemView.setItem()
    2. ti.modules.titanium
      TiMapView.handleMessage
      1. ti.modules.titanium.map.TiOverlayItemView.setItem(TiOverlayItemView.java:191)
      2. ti.modules.titanium.map.TiMapView.showAnnotation(TiMapView.java:493)
      3. ti.modules.titanium.map.TiMapView.doSelectAnnotation(TiMapView.java:727)
      4. ti.modules.titanium.map.TiMapView.handleMessage(TiMapView.java:471)
      4 frames
    3. Android Platform
      ActivityThread.main
      1. android.os.Handler.dispatchMessage(Handler.java:95)
      2. android.os.Looper.loop(Looper.java:123)
      3. android.app.ActivityThread.main(ActivityThread.java:4627)
      3 frames
    4. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:521)
      2 frames
    5. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
      2 frames
    6. Android Platform
      NativeStart.main
      1. dalvik.system.NativeStart.main(Native Method)
      1 frame