java.lang.NullPointerException

Appcelerator JIRA | Benjamin Jeanjean | 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

    h2. Problem If the {{window}} property is omitted when a [Titanium.UI.Tab|http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Tab-object#properties] is created, despite setting it directly afterwards with the {{setWindow()}} method, it will cause the app to crash. The crash will occur when the {{open}} method is called on the {{TabGroup}}. h2. Test case {code:lang=javascript|title=app.js} Ti.UI.setBackgroundColor('#000'); var tabGroup = Ti.UI.createTabGroup(); var win1 = Ti.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Ti.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', }); tab1.window = win1; var win2 = Ti.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); var tab2 = Ti.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', }); tab2.setWindow(win2); tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.open(); {code} h2. Logs {code:lang=none} 01-05 17:59:57.370: ERROR/TiApplication(6157): (main) [1,4512] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 1.8.0.1,2011/12/22 13:09,fbdc96f 01-05 17:59:57.370: ERROR/TiApplication(6157): java.lang.NullPointerException 01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204) 01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314) 01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95) 01-05 17:59:57.370: ERROR/TiApplication(6157): at android.os.Handler.dispatchMessage(Handler.java:95) 01-05 17:59:57.370: ERROR/TiApplication(6157): at android.os.Looper.loop(Looper.java:123) 01-05 17:59:57.370: ERROR/TiApplication(6157): at android.app.ActivityThread.main(ActivityThread.java:3691) 01-05 17:59:57.370: ERROR/TiApplication(6157): at java.lang.reflect.Method.invokeNative(Native Method) 01-05 17:59:57.370: ERROR/TiApplication(6157): at java.lang.reflect.Method.invoke(Method.java:507) 01-05 17:59:57.370: ERROR/TiApplication(6157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 01-05 17:59:57.370: ERROR/TiApplication(6157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 01-05 17:59:57.370: ERROR/TiApplication(6157): at dalvik.system.NativeStart.main(Native Method) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): FATAL EXCEPTION: main 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): java.lang.NullPointerException 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.os.Handler.dispatchMessage(Handler.java:95) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.os.Looper.loop(Looper.java:123) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.app.ActivityThread.main(ActivityThread.java:3691) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at java.lang.reflect.Method.invokeNative(Native Method) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at java.lang.reflect.Method.invoke(Method.java:507) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at dalvik.system.NativeStart.main(Native Method) {code}

    Appcelerator JIRA | 5 years ago | Benjamin Jeanjean
    java.lang.NullPointerException
  2. 0

    h2. Problem If the {{window}} property is omitted when a [Titanium.UI.Tab|http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Tab-object#properties] is created, despite setting it directly afterwards with the {{setWindow()}} method, it will cause the app to crash. The crash will occur when the {{open}} method is called on the {{TabGroup}}. h2. Test case {code:lang=javascript|title=app.js} Ti.UI.setBackgroundColor('#000'); var tabGroup = Ti.UI.createTabGroup(); var win1 = Ti.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Ti.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', }); tab1.window = win1; var win2 = Ti.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); var tab2 = Ti.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', }); tab2.setWindow(win2); tabGroup.addTab(tab1); tabGroup.addTab(tab2); tabGroup.open(); {code} h2. Logs {code:lang=none} 01-05 17:59:57.370: ERROR/TiApplication(6157): (main) [1,4512] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 1.8.0.1,2011/12/22 13:09,fbdc96f 01-05 17:59:57.370: ERROR/TiApplication(6157): java.lang.NullPointerException 01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204) 01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314) 01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95) 01-05 17:59:57.370: ERROR/TiApplication(6157): at android.os.Handler.dispatchMessage(Handler.java:95) 01-05 17:59:57.370: ERROR/TiApplication(6157): at android.os.Looper.loop(Looper.java:123) 01-05 17:59:57.370: ERROR/TiApplication(6157): at android.app.ActivityThread.main(ActivityThread.java:3691) 01-05 17:59:57.370: ERROR/TiApplication(6157): at java.lang.reflect.Method.invokeNative(Native Method) 01-05 17:59:57.370: ERROR/TiApplication(6157): at java.lang.reflect.Method.invoke(Method.java:507) 01-05 17:59:57.370: ERROR/TiApplication(6157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 01-05 17:59:57.370: ERROR/TiApplication(6157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 01-05 17:59:57.370: ERROR/TiApplication(6157): at dalvik.system.NativeStart.main(Native Method) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): FATAL EXCEPTION: main 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): java.lang.NullPointerException 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.os.Handler.dispatchMessage(Handler.java:95) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.os.Looper.loop(Looper.java:123) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.app.ActivityThread.main(ActivityThread.java:3691) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at java.lang.reflect.Method.invokeNative(Native Method) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at java.lang.reflect.Method.invoke(Method.java:507) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at dalvik.system.NativeStart.main(Native Method) {code}

    Appcelerator JIRA | 5 years ago | Benjamin Jeanjean
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup()
    2. ti.modules.titanium
      TabGroupProxy.handleMessage
      1. ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204)
      2. ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314)
      3. ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95)
      3 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:3691)
      3 frames
    4. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:507)
      2 frames
    5. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
      2 frames
    6. Android Platform
      NativeStart.main
      1. dalvik.system.NativeStart.main(Native Method)
      1 frame