java.lang.NullPointerException

Appcelerator JIRA | Romain Salles | 4 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

    h1. The issue It is not possible to create a window/tabgroup with the property *navBarHidden* set to *true*. Otherwise the app crashes with this error : {code} 05-21 14:34:41.200: E/TiApplication(14621): (main) [98,98] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.1.0,2013/04/15 18:46,57634ef 05-21 14:34:41.200: E/TiApplication(14621): java.lang.NullPointerException 05-21 14:34:41.200: E/TiApplication(14621): at org.appcelerator.titanium.proxy.ActionBarProxy.handleSetTitle(ActionBarProxy.java:154) 05-21 14:34:41.200: E/TiApplication(14621): at org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:207) 05-21 14:34:41.200: E/TiApplication(14621): at android.os.Handler.dispatchMessage(Handler.java:95) 05-21 14:34:41.200: E/TiApplication(14621): at android.os.Looper.loop(Looper.java:137) 05-21 14:34:41.200: E/TiApplication(14621): at android.app.ActivityThread.main(ActivityThread.java:4507) 05-21 14:34:41.200: E/TiApplication(14621): at java.lang.reflect.Method.invokeNative(Native Method) 05-21 14:34:41.200: E/TiApplication(14621): at java.lang.reflect.Method.invoke(Method.java:511) 05-21 14:34:41.200: E/TiApplication(14621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 05-21 14:34:41.200: E/TiApplication(14621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 05-21 14:34:41.200: E/TiApplication(14621): at dalvik.system.NativeStart.main(Native Method) {code} h1. Code to reproduce app.js : {code:javascript} (function() { // code with window var win = Ti.UI.createWindow({navBarHidden: true, backgroundColor: '#F00'}); win.addEventListener("open", function(event) { var actionBar = event.source.getActivity().actionBar; if (actionBar) { actionBar.setTitle("Test"); } }); win.open(); // Code with tabbar /*var tabGroup = Ti.UI.createTabGroup({navBarHidden: true}); tabGroup.addEventListener("open", function() { var actionBar = tabGroup.getActivity().actionBar; if (actionBar) { actionBar.setTitle("Test"); } }); tabGroup.open();*/ })(); {code} tiapp.xml : {code:xml} <?xml version="1.0" encoding="UTF-8"?> <ti:app xmlns:ti="http://ti.appcelerator.org"> <id>com.tab.test</id> <name>TabTest</name> <version>1.0</version> <publisher>johndoe</publisher> <url>http://</url> <description>not specified</description> <copyright>not specified</copyright> <icon>appicon.png</icon> <persistent-wifi>false</persistent-wifi> <prerendered-icon>false</prerendered-icon> <statusbar-style>default</statusbar-style> <statusbar-hidden>false</statusbar-hidden> <fullscreen>false</fullscreen> <navbar-hidden>false</navbar-hidden> <analytics>false</analytics> <guid>e96a483e-41b2-4212-b78a-910612e01548</guid> <property name="ti.ui.defaultunit" type="string">system</property> <iphone> <orientations device="iphone"> <orientation>Ti.UI.PORTRAIT</orientation> </orientations> <orientations device="ipad"> <orientation>Ti.UI.PORTRAIT</orientation> <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation> <orientation>Ti.UI.LANDSCAPE_LEFT</orientation> <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation> </orientations> </iphone> <android xmlns:android="http://schemas.android.com/apk/res/android"> <tool-api-level>17</tool-api-level> <manifest> <uses-sdk android:minSdkVersion="8"/> <!-- TI_MANIFEST --> <application android:debuggable="false" android:icon="@drawable/appicon" android:label="TabTest" android:name="TabtestApplication" android:theme="@android:style/Theme.Holo.Light"> <!-- TI_APPLICATION --> <activity android:configChanges="keyboardHidden|orientation" android:label="TabTest" android:name=".TabtestActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiActivity"/> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiTranslucentActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiModalActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboardHidden|orientation" android:name="ti.modules.titanium.ui.TiTabActivity"/> </application> </manifest> </android> <modules/> <deployment-targets> <target device="blackberry">false</target> <target device="android">true</target> <target device="ipad">false</target> <target device="iphone">false</target> <target device="mobileweb">false</target> </deployment-targets> <sdk-version>3.1.0.GA</sdk-version> </ti:app> {code} h1. Devices used This problem is only reproducible on devices using *Holo*. I have tested on these devices : - Samsung S2 (GT-I9100P), android 4.0.3 -> *crash* (supports Holo) - Nexus S, android 4.1.2 -> *crash* (supports Holo) - Samsung S3 (GT-I93000), android 4.1.2 -> *crash* (supports Holo) - HTC Desire HD A9191, android 2.2 -> *ok* (does not supports Holo) - Samsung GT-S5830, android 2.3.3 -> *ok* (does not support Holo) - HTC Wildfire A3333, android 2.2.1 -> *ok* (does not support Holo)

    Appcelerator JIRA | 4 years ago | Romain Salles
    java.lang.NullPointerException
  2. 0

    h1. The issue It is not possible to create a window/tabgroup with the property *navBarHidden* set to *true*. Otherwise the app crashes with this error : {code} 05-21 14:34:41.200: E/TiApplication(14621): (main) [98,98] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.1.0,2013/04/15 18:46,57634ef 05-21 14:34:41.200: E/TiApplication(14621): java.lang.NullPointerException 05-21 14:34:41.200: E/TiApplication(14621): at org.appcelerator.titanium.proxy.ActionBarProxy.handleSetTitle(ActionBarProxy.java:154) 05-21 14:34:41.200: E/TiApplication(14621): at org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:207) 05-21 14:34:41.200: E/TiApplication(14621): at android.os.Handler.dispatchMessage(Handler.java:95) 05-21 14:34:41.200: E/TiApplication(14621): at android.os.Looper.loop(Looper.java:137) 05-21 14:34:41.200: E/TiApplication(14621): at android.app.ActivityThread.main(ActivityThread.java:4507) 05-21 14:34:41.200: E/TiApplication(14621): at java.lang.reflect.Method.invokeNative(Native Method) 05-21 14:34:41.200: E/TiApplication(14621): at java.lang.reflect.Method.invoke(Method.java:511) 05-21 14:34:41.200: E/TiApplication(14621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 05-21 14:34:41.200: E/TiApplication(14621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 05-21 14:34:41.200: E/TiApplication(14621): at dalvik.system.NativeStart.main(Native Method) {code} h1. Code to reproduce app.js : {code:javascript} (function() { // code with window var win = Ti.UI.createWindow({navBarHidden: true, backgroundColor: '#F00'}); win.addEventListener("open", function(event) { var actionBar = event.source.getActivity().actionBar; if (actionBar) { actionBar.setTitle("Test"); } }); win.open(); // Code with tabbar /*var tabGroup = Ti.UI.createTabGroup({navBarHidden: true}); tabGroup.addEventListener("open", function() { var actionBar = tabGroup.getActivity().actionBar; if (actionBar) { actionBar.setTitle("Test"); } }); tabGroup.open();*/ })(); {code} tiapp.xml : {code:xml} <?xml version="1.0" encoding="UTF-8"?> <ti:app xmlns:ti="http://ti.appcelerator.org"> <id>com.tab.test</id> <name>TabTest</name> <version>1.0</version> <publisher>johndoe</publisher> <url>http://</url> <description>not specified</description> <copyright>not specified</copyright> <icon>appicon.png</icon> <persistent-wifi>false</persistent-wifi> <prerendered-icon>false</prerendered-icon> <statusbar-style>default</statusbar-style> <statusbar-hidden>false</statusbar-hidden> <fullscreen>false</fullscreen> <navbar-hidden>false</navbar-hidden> <analytics>false</analytics> <guid>e96a483e-41b2-4212-b78a-910612e01548</guid> <property name="ti.ui.defaultunit" type="string">system</property> <iphone> <orientations device="iphone"> <orientation>Ti.UI.PORTRAIT</orientation> </orientations> <orientations device="ipad"> <orientation>Ti.UI.PORTRAIT</orientation> <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation> <orientation>Ti.UI.LANDSCAPE_LEFT</orientation> <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation> </orientations> </iphone> <android xmlns:android="http://schemas.android.com/apk/res/android"> <tool-api-level>17</tool-api-level> <manifest> <uses-sdk android:minSdkVersion="8"/> <!-- TI_MANIFEST --> <application android:debuggable="false" android:icon="@drawable/appicon" android:label="TabTest" android:name="TabtestApplication" android:theme="@android:style/Theme.Holo.Light"> <!-- TI_APPLICATION --> <activity android:configChanges="keyboardHidden|orientation" android:label="TabTest" android:name=".TabtestActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiActivity"/> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiTranslucentActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiModalActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboardHidden|orientation" android:name="ti.modules.titanium.ui.TiTabActivity"/> </application> </manifest> </android> <modules/> <deployment-targets> <target device="blackberry">false</target> <target device="android">true</target> <target device="ipad">false</target> <target device="iphone">false</target> <target device="mobileweb">false</target> </deployment-targets> <sdk-version>3.1.0.GA</sdk-version> </ti:app> {code} h1. Devices used This problem is only reproducible on devices using *Holo*. I have tested on these devices : - Samsung S2 (GT-I9100P), android 4.0.3 -> *crash* (supports Holo) - Nexus S, android 4.1.2 -> *crash* (supports Holo) - Samsung S3 (GT-I93000), android 4.1.2 -> *crash* (supports Holo) - HTC Desire HD A9191, android 2.2 -> *ok* (does not supports Holo) - Samsung GT-S5830, android 2.3.3 -> *ok* (does not support Holo) - HTC Wildfire A3333, android 2.2.1 -> *ok* (does not support Holo)

    Appcelerator JIRA | 4 years ago | Romain Salles
    java.lang.NullPointerException
  3. 0

    h1. The issue It is not possible to call *setDisplayHomeAsUp* on the activity of a window with the *navBarHidden* property set to *true*. Otherwise, we get this error : {code} 05-21 15:36:54.035: E/TiApplication(21464): (main) [163,163] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.1.0,2013/04/15 18:46,57634ef 05-21 15:36:54.035: E/TiApplication(21464): java.lang.NullPointerException 05-21 15:36:54.035: E/TiApplication(21464): at org.appcelerator.titanium.proxy.ActionBarProxy.handlesetDisplayHomeAsUp(ActionBarProxy.java:178) 05-21 15:36:54.035: E/TiApplication(21464): at org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:201) 05-21 15:36:54.035: E/TiApplication(21464): at android.os.Handler.dispatchMessage(Handler.java:95) 05-21 15:36:54.035: E/TiApplication(21464): at android.os.Looper.loop(Looper.java:137) 05-21 15:36:54.035: E/TiApplication(21464): at android.app.ActivityThread.main(ActivityThread.java:4507) 05-21 15:36:54.035: E/TiApplication(21464): at java.lang.reflect.Method.invokeNative(Native Method) 05-21 15:36:54.035: E/TiApplication(21464): at java.lang.reflect.Method.invoke(Method.java:511) 05-21 15:36:54.035: E/TiApplication(21464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 05-21 15:36:54.035: E/TiApplication(21464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 05-21 15:36:54.035: E/TiApplication(21464): at dalvik.system.NativeStart.main(Native Method) 05-21 15:36:54.045: E/AndroidRuntime(21464): FATAL EXCEPTION: main {code} h1. Code to reproduce app.js : {code:javascript} function openNewWindow() { var newWin = Ti.UI.createWindow({navBarHidden: true, backgroundColor: '#0F0'}); newWin.addEventListener("open", function() { var newActionBar = this.activity.actionBar; if (newActionBar) { newActionBar.setDisplayHomeAsUp(true); } }); newWin.open(); } (function() { var win = Ti.UI.createWindow({backgroundColor: '#F00'}); win.addEventListener("open", openNewWindow); win.open(); })(); {code} tiapp.xml : {code:xml} <?xml version="1.0" encoding="UTF-8"?> <ti:app xmlns:ti="http://ti.appcelerator.org"> <id>com.tab.test</id> <name>TabTest</name> <version>1.0</version> <publisher>johndoe</publisher> <url>http://</url> <description>not specified</description> <copyright>not specified</copyright> <icon>appicon.png</icon> <persistent-wifi>false</persistent-wifi> <prerendered-icon>false</prerendered-icon> <statusbar-style>default</statusbar-style> <statusbar-hidden>false</statusbar-hidden> <fullscreen>false</fullscreen> <navbar-hidden>false</navbar-hidden> <analytics>false</analytics> <guid>e96a483e-41b2-4212-b78a-910612e01548</guid> <property name="ti.ui.defaultunit" type="string">system</property> <iphone> <orientations device="iphone"> <orientation>Ti.UI.PORTRAIT</orientation> </orientations> <orientations device="ipad"> <orientation>Ti.UI.PORTRAIT</orientation> <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation> <orientation>Ti.UI.LANDSCAPE_LEFT</orientation> <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation> </orientations> </iphone> <android xmlns:android="http://schemas.android.com/apk/res/android"> <tool-api-level>17</tool-api-level> <manifest> <uses-sdk android:minSdkVersion="8"/> <!-- TI_MANIFEST --> <application android:debuggable="false" android:icon="@drawable/appicon" android:label="TabTest" android:name="TabtestApplication" android:theme="@android:style/Theme.Holo.Light"> <!-- TI_APPLICATION --> <activity android:configChanges="keyboardHidden|orientation" android:label="TabTest" android:name=".TabtestActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiActivity"/> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiTranslucentActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboardHidden|orientation" android:name="org.appcelerator.titanium.TiModalActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboardHidden|orientation" android:name="ti.modules.titanium.ui.TiTabActivity"/> </application> </manifest> </android> <modules/> <deployment-targets> <target device="blackberry">false</target> <target device="android">true</target> <target device="ipad">false</target> <target device="iphone">false</target> <target device="mobileweb">false</target> </deployment-targets> <sdk-version>3.1.0.GA</sdk-version> </ti:app> {code} If we set navBarHidden to false, the app will work : {code:javascript} var newWin = Ti.UI.createWindow({navBarHidden: false, backgroundColor: '#0F0'}); {code} instead of {code:javascript} var newWin = Ti.UI.createWindow({navBarHidden: true, backgroundColor: '#0F0'}); {code} h1. Devices used This problem is only reproducible on devices using *Holo*. I have tested on these devices : - Samsung S2 (GT-I9100P), android 4.0.3 -> *crash* (supports Holo) - Nexus S, android 4.1.2 -> *crash* (supports Holo) - Samsung S3 (GT-I93000), android 4.1.2 -> *crash* (supports Holo) - HTC Desire HD A9191, android 2.2 -> *ok* (does not supports Holo) - Samsung GT-S5830, android 2.3.3 -> *ok* (does not support Holo) - HTC Wildfire A3333, android 2.2.1 -> *ok* (does not support Holo)

    Appcelerator JIRA | 4 years ago | Romain Salles
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    h1. Summary On some Android devices, the app crashes after setting the 'title' property of the actionBar. h1. Test case Coffeescript: {quote} @_tabGroup = Titanium.UI.createTabGroup() actionBar = @_tabGroup.getActivity().actionBar actionBar?.title = "Compass" {quote} Javascript: {quote} this._tabGroup = Titanium.UI.createTabGroup(); var actionBar; actionBar = _this._tabGroup.getActivity().actionBar; if (actionBar != null) actionBar.title = "Compass"; {quote} The app crashes with the following stack-trace: {noformat} java.lang.NullPointerException at org.appcelerator.titanium.proxy.ActionBarProxy.handleSetTitle(ActionBarProxy.java:154) at org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:207) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5086) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) at dalvik.system.NativeStart.main(Native Method) {noformat} According to user-reports, at least the following devices are affected: * Android devices running HTC Sense * HP tablet with cyanogenmod * Aldi Wolfgang AT-AS45IPS h1. Resolution I just submitted a [Pull request|https://github.com/appcelerator/titanium_mobile/pull/4437] for [TIMOB-14215|https://jira.appcelerator.org/browse/TIMOB-14215]. These issues are related. I can confirm that the changes in this pull request resolve both issues.

    Appcelerator JIRA | 4 years ago | Tijs Zwinkels
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.appcelerator.titanium.proxy.ActionBarProxy.handleSetTitle()
    2. org.appcelerator.titanium
      ActionBarProxy.handleMessage
      1. org.appcelerator.titanium.proxy.ActionBarProxy.handleSetTitle(ActionBarProxy.java:154)
      2. org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:207)
      2 frames
    3. Android Platform
      ActivityThread.main
      1. android.os.Handler.dispatchMessage(Handler.java:95)
      2. android.os.Looper.loop(Looper.java:137)
      3. android.app.ActivityThread.main(ActivityThread.java:4507)
      3 frames
    4. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invokeNative(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:511)
      2 frames
    5. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
      2 frames
    6. Android Platform
      NativeStart.main
      1. dalvik.system.NativeStart.main(Native Method)
      1 frame