java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference

Appcelerator JIRA | Alex Bernier | 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

    ListView is crashing when reaching the end of the list. This same test case works without crashing with Ti SDK 4.0.0.Beta2. Steps to reproduce: # Load code below with Ti SDK 4.1.0.v20150410061234 # Tap the "Append 10 items" button # Scroll all the way to the bottom # Observer app crash Test case: {code} var win = Ti.UI.createWindow({ backgroundColor : "#ffffff", layout : "absolute" }); win.open(); var appendButton = Ti.UI.createButton({ title : "Append 10 items", height : "10%", top : "5%" }); appendButton.addEventListener("click", function() { appendData(); }); win.add(appendButton); var screenWidth = Ti.Platform.displayCaps.platformWidth; var listSection = Ti.UI.createListSection(); var listView = Ti.UI.createListView({ backgroundColor : "#cccccc", top : "20%", height : "80%", templates : { "photoWithCaption" : { properties : { layout : "vertical", height : Ti.UI.SIZE }, childTemplates : [{ type : "Ti.UI.ImageView", bindId : "photo", properties : { height : screenWidth, width : screenWidth, preventDefaultImage : true } }, { type : "Ti.UI.TextArea", bindId : "caption", properties : { backgroundColor : "#ffffff", height : Ti.UI.SIZE, left : 10, right : 10, editable : false, scrollable : false } }] } }, defaultItemTemplate : "photoWithCaption" }); listView.setSections([listSection]); win.add(listView); function appendData() { var data = []; for (var i = 0; i < 10; i++) { var text = "This a caption #" + (i + 1) + ", and it may disappear when an append of new data happens on the parent ListView."; data.push({ template : "photoWithCaption", photo : { image : "http://thecatapi.com/api/images/get?format=src&type=jpg&size=small" }, caption : { attributedString : Titanium.UI.createAttributedString({ text : text, attributes : [{ type : Ti.UI.ATTRIBUTE_FONT, value : { font : { fontSize : 14 } }, range : [0, text.length] }, { type : Ti.UI.ATTRIBUTE_FOREGROUND_COLOR, value : "#000000", range : [0, text.length] }] }) } }); } listSection.appendItems(data); } {code} Stack trace: {code} 04-10 13:52:35.211: E/TiApplication(19289): (main) [30186,32990] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference; Titanium 4.1.0,2015/04/10 06:13,29ba994 04-10 13:52:35.211: E/TiApplication(19289): java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference 04-10 13:52:35.211: E/TiApplication(19289): at ti.modules.titanium.ui.widget.listview.TiListView$1.onScrollStateChanged(TiListView.java:337) 04-10 13:52:35.211: E/TiApplication(19289): at android.widget.AbsListView.reportScrollStateChange(AbsListView.java:4335) 04-10 13:52:35.211: E/TiApplication(19289): at android.widget.AbsListView$FlingRunnable.endFling(AbsListView.java:4466) 04-10 13:52:35.211: E/TiApplication(19289): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4601) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer.doCallbacks(Choreographer.java:580) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer.doFrame(Choreographer.java:549) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 04-10 13:52:35.211: E/TiApplication(19289): at android.os.Handler.handleCallback(Handler.java:739) 04-10 13:52:35.211: E/TiApplication(19289): at android.os.Handler.dispatchMessage(Handler.java:95) 04-10 13:52:35.211: E/TiApplication(19289): at android.os.Looper.loop(Looper.java:135) 04-10 13:52:35.211: E/TiApplication(19289): at android.app.ActivityThread.main(ActivityThread.java:5254) 04-10 13:52:35.211: E/TiApplication(19289): at java.lang.reflect.Method.invoke(Native Method) 04-10 13:52:35.211: E/TiApplication(19289): at java.lang.reflect.Method.invoke(Method.java:372) 04-10 13:52:35.211: E/TiApplication(19289): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 04-10 13:52:35.211: E/TiApplication(19289): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 04-10 13:52:35.234: E/AndroidRuntime(19289): FATAL EXCEPTION: main 04-10 13:52:35.234: E/AndroidRuntime(19289): Process: blah, PID: 19289 04-10 13:52:35.234: E/AndroidRuntime(19289): java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference 04-10 13:52:35.234: E/AndroidRuntime(19289): at ti.modules.titanium.ui.widget.listview.TiListView$1.onScrollStateChanged(TiListView.java:337) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.widget.AbsListView.reportScrollStateChange(AbsListView.java:4335) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.widget.AbsListView$FlingRunnable.endFling(AbsListView.java:4466) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4601) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer.doCallbacks(Choreographer.java:580) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer.doFrame(Choreographer.java:549) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.os.Handler.handleCallback(Handler.java:739) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.os.Handler.dispatchMessage(Handler.java:95) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.os.Looper.loop(Looper.java:135) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.app.ActivityThread.main(ActivityThread.java:5254) 04-10 13:52:35.234: E/AndroidRuntime(19289): at java.lang.reflect.Method.invoke(Native Method) 04-10 13:52:35.234: E/AndroidRuntime(19289): at java.lang.reflect.Method.invoke(Method.java:372) 04-10 13:52:35.234: E/AndroidRuntime(19289): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 04-10 13:52:35.234: E/AndroidRuntime(19289): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) {code}

    Appcelerator JIRA | 2 years ago | Alex Bernier
    java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference
  2. 0

    ListView is crashing when reaching the end of the list. This same test case works without crashing with Ti SDK 4.0.0.Beta2. Steps to reproduce: # Load code below with Ti SDK 4.1.0.v20150410061234 # Tap the "Append 10 items" button # Scroll all the way to the bottom # Observer app crash Test case: {code} var win = Ti.UI.createWindow({ backgroundColor : "#ffffff", layout : "absolute" }); win.open(); var appendButton = Ti.UI.createButton({ title : "Append 10 items", height : "10%", top : "5%" }); appendButton.addEventListener("click", function() { appendData(); }); win.add(appendButton); var screenWidth = Ti.Platform.displayCaps.platformWidth; var listSection = Ti.UI.createListSection(); var listView = Ti.UI.createListView({ backgroundColor : "#cccccc", top : "20%", height : "80%", templates : { "photoWithCaption" : { properties : { layout : "vertical", height : Ti.UI.SIZE }, childTemplates : [{ type : "Ti.UI.ImageView", bindId : "photo", properties : { height : screenWidth, width : screenWidth, preventDefaultImage : true } }, { type : "Ti.UI.TextArea", bindId : "caption", properties : { backgroundColor : "#ffffff", height : Ti.UI.SIZE, left : 10, right : 10, editable : false, scrollable : false } }] } }, defaultItemTemplate : "photoWithCaption" }); listView.setSections([listSection]); win.add(listView); function appendData() { var data = []; for (var i = 0; i < 10; i++) { var text = "This a caption #" + (i + 1) + ", and it may disappear when an append of new data happens on the parent ListView."; data.push({ template : "photoWithCaption", photo : { image : "http://thecatapi.com/api/images/get?format=src&type=jpg&size=small" }, caption : { attributedString : Titanium.UI.createAttributedString({ text : text, attributes : [{ type : Ti.UI.ATTRIBUTE_FONT, value : { font : { fontSize : 14 } }, range : [0, text.length] }, { type : Ti.UI.ATTRIBUTE_FOREGROUND_COLOR, value : "#000000", range : [0, text.length] }] }) } }); } listSection.appendItems(data); } {code} Stack trace: {code} 04-10 13:52:35.211: E/TiApplication(19289): (main) [30186,32990] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference; Titanium 4.1.0,2015/04/10 06:13,29ba994 04-10 13:52:35.211: E/TiApplication(19289): java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference 04-10 13:52:35.211: E/TiApplication(19289): at ti.modules.titanium.ui.widget.listview.TiListView$1.onScrollStateChanged(TiListView.java:337) 04-10 13:52:35.211: E/TiApplication(19289): at android.widget.AbsListView.reportScrollStateChange(AbsListView.java:4335) 04-10 13:52:35.211: E/TiApplication(19289): at android.widget.AbsListView$FlingRunnable.endFling(AbsListView.java:4466) 04-10 13:52:35.211: E/TiApplication(19289): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4601) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer.doCallbacks(Choreographer.java:580) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer.doFrame(Choreographer.java:549) 04-10 13:52:35.211: E/TiApplication(19289): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 04-10 13:52:35.211: E/TiApplication(19289): at android.os.Handler.handleCallback(Handler.java:739) 04-10 13:52:35.211: E/TiApplication(19289): at android.os.Handler.dispatchMessage(Handler.java:95) 04-10 13:52:35.211: E/TiApplication(19289): at android.os.Looper.loop(Looper.java:135) 04-10 13:52:35.211: E/TiApplication(19289): at android.app.ActivityThread.main(ActivityThread.java:5254) 04-10 13:52:35.211: E/TiApplication(19289): at java.lang.reflect.Method.invoke(Native Method) 04-10 13:52:35.211: E/TiApplication(19289): at java.lang.reflect.Method.invoke(Method.java:372) 04-10 13:52:35.211: E/TiApplication(19289): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 04-10 13:52:35.211: E/TiApplication(19289): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 04-10 13:52:35.234: E/AndroidRuntime(19289): FATAL EXCEPTION: main 04-10 13:52:35.234: E/AndroidRuntime(19289): Process: blah, PID: 19289 04-10 13:52:35.234: E/AndroidRuntime(19289): java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference 04-10 13:52:35.234: E/AndroidRuntime(19289): at ti.modules.titanium.ui.widget.listview.TiListView$1.onScrollStateChanged(TiListView.java:337) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.widget.AbsListView.reportScrollStateChange(AbsListView.java:4335) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.widget.AbsListView$FlingRunnable.endFling(AbsListView.java:4466) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4601) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer.doCallbacks(Choreographer.java:580) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer.doFrame(Choreographer.java:549) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.os.Handler.handleCallback(Handler.java:739) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.os.Handler.dispatchMessage(Handler.java:95) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.os.Looper.loop(Looper.java:135) 04-10 13:52:35.234: E/AndroidRuntime(19289): at android.app.ActivityThread.main(ActivityThread.java:5254) 04-10 13:52:35.234: E/AndroidRuntime(19289): at java.lang.reflect.Method.invoke(Native Method) 04-10 13:52:35.234: E/AndroidRuntime(19289): at java.lang.reflect.Method.invoke(Method.java:372) 04-10 13:52:35.234: E/AndroidRuntime(19289): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 04-10 13:52:35.234: E/AndroidRuntime(19289): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) {code}

    Appcelerator JIRA | 2 years ago | Alex Bernier
    java.lang.NullPointerException: Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to read from field 'java.lang.Object android.util.Pair.second' on a null object reference

      at ti.modules.titanium.ui.widget.listview.TiListView$1.onScrollStateChanged()
    2. ti.modules.titanium
      TiListView$1.onScrollStateChanged
      1. ti.modules.titanium.ui.widget.listview.TiListView$1.onScrollStateChanged(TiListView.java:337)
      1 frame
    3. Android Platform
      ActivityThread.main
      1. android.widget.AbsListView.reportScrollStateChange(AbsListView.java:4335)
      2. android.widget.AbsListView$FlingRunnable.endFling(AbsListView.java:4466)
      3. android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4601)
      4. android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
      5. android.view.Choreographer.doCallbacks(Choreographer.java:580)
      6. android.view.Choreographer.doFrame(Choreographer.java:549)
      7. android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
      8. android.os.Handler.handleCallback(Handler.java:739)
      9. android.os.Handler.dispatchMessage(Handler.java:95)
      10. android.os.Looper.loop(Looper.java:135)
      11. android.app.ActivityThread.main(ActivityThread.java:5254)
      11 frames
    4. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    5. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
      2 frames