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 :
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 to reproduce
app.js :
(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();*/
})();
tiapp.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>
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)
Note that if you change :
into :
the app will not crash
I just submitted a [pull request](https://github.com/appcelerator/titanium_mobile/pull/4437) that resolves this issue for me. [[TC-2577]] is an related issue as it causes a crash on the same source line, and is resolved by the same patch.
You need to set the targetSDK to 11+ in the manifest to enable ActionBar. Please see http://docs.appcelerator.com/titanium/latest/#!/guide/Android_Action_Bar for more info. Though we should be performing null checks and warn users when ActionBar is not available.
master PR: https://github.com/appcelerator/titanium_mobile/pull/4453
PR: https://github.com/appcelerator/titanium_mobile/pull/4453
Verified fixed. TiSDK 3.2.0.v20131018154951 CLI 3.2.0 Titanium Studio 3.2.0.201310181940 Closing.