Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27188] Android: TabGroup crashes if tab "title" property is not set as of 8.0.2

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-07-02T22:09:22.000+0000
Affected Version/sRelease 8.0.2
Fix Version/sRelease 8.1.0
ComponentsAndroid
LabelsTabGroup, android, engSchedule, regression, tab, title
ReporterAndreas Pingas
AssigneeJoshua Quick
Created2019-06-26T21:28:59.000+0000
Updated2019-07-02T22:09:22.000+0000

Description

*Summary:* As of Titanium 8.0.2, setting up a TabGroup tab without setting the "title" property will cause a crash. This happens to both the top and bottom tab styles. *Use-Case:* Apps which want to show icon-only tab groups. *Steps to reproduce:*

Create a Classic "Default Project".

Set up the project to build with Titanium 8.0.2.GA.

Replace the project's "app.js" with the code below.

Build and run on Android

function createTab(title) {
	var window = Ti.UI.createWindow({ title: title });
	window.add(Ti.UI.createLabel({ text: title + " View" }));
	var tab = Ti.UI.createTab({
// Setting "title" property to empty string works-around the problem.
//		title: "",
		icon: "/assets/images/tab1.png",
		window: window,
	});
	return tab;
}

var tabGroupSettings = {
	tabs: [createTab("Tab 1"), createTab("Tab 2"), createTab("Tab 3")],
};
if (Ti.Android) {
//	tabGroupSettings.style = Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION;
}
var tabGroup = Ti.UI.createTabGroup(tabGroupSettings);
tabGroup.open();
*Result:* App crashes with the following stack trace when using the top bar style.
[ERROR] :  TiExceptionHandler: (main) [122,122] Unable to start activity ComponentInfo{com.appcelerator.testing/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
[ERROR] :  TiExceptionHandler:
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUITabLayoutTabGroup.updateTabTitle(TiUITabLayoutTabGroup.java:222)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUITabLayoutTabGroup.addTabItemInController(TiUITabLayoutTabGroup.java:155)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup.addTab(TiUIAbstractTabGroup.java:241)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:448)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.onWindowActivityCreated(TabGroupProxy.java:430)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:752)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
[ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:7144)
[ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:7135)
[ERROR] :  TiExceptionHandler:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
[ERROR] :  TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:106)
[ERROR] :  TiExceptionHandler:     android.os.Looper.loop(Looper.java:193)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:6680)
[ERROR] :  TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  TiExceptionHandler:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[ERROR] :  TiExceptionHandler:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
When using the bottom tab style, it crashes with the following stack trace...
[ERROR] :  TiExceptionHandler: (main) [114,114] Unable to start activity ComponentInfo{com.appcelerator.testing/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
[ERROR] :  TiExceptionHandler:
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.updateTabTitle(TiUIBottomNavigationTabGroup.java:262)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.updateDrawablesAfterNewItem(TiUIBottomNavigationTabGroup.java:162)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.addTabItemInController(TiUIBottomNavigationTabGroup.java:150)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup.addTab(TiUIAbstractTabGroup.java:241)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:448)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.TabGroupProxy.onWindowActivityCreated(TabGroupProxy.java:430)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:752)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47)
[ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:7144)
[ERROR] :  TiExceptionHandler:     android.app.Activity.performCreate(Activity.java:7135)
[ERROR] :  TiExceptionHandler:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
[ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
[ERROR] :  TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:106)
[ERROR] :  TiExceptionHandler:     android.os.Looper.loop(Looper.java:193)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:6680)
[ERROR] :  TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  TiExceptionHandler:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[ERROR] :  TiExceptionHandler:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
*Work-around:* Set tab title to empty string like this...
var tab = Ti.UI.createTab({
	title: "",    // <- This works-around issue.
	icon: "/assets/images/tab1.png",
	window: window,
});

Comments

  1. Joshua Quick 2019-06-27

    I am able to reproduce this issue. It happens because the tabs are missing titles. You can work-around it by setting the titles to empty strings like this...
       var tab1 = Ti.UI.createTab({
       	title: "",
       	window: window1
       });
       var tab2 = Ti.UI.createTab({
       	title: "",
       	window: window2
       });
       
  2. Joshua Quick 2019-06-27

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11001
  3. Andreas Pingas 2019-06-27

    thanks :)
  4. Joshua Quick 2019-06-27

    Thanks for reporting this [~andreas.pingas]. We've added a unit test to help make sure this issue never happens again.
  5. Joshua Quick 2019-06-27

    PR (8.1.x): https://github.com/appcelerator/titanium_mobile/pull/11004
  6. Keerthi Mahalingam 2019-06-27

    FR Passed.Waiting on Jenkins
  7. Christopher Williams 2019-07-01

    Merged to 8_1_X, waiting on build against master to merge that PR...
  8. Keerthi Mahalingam 2019-07-02

    Verified the fix on sdk 8.2.0.v20190702112137 and 8.1.0.v20190702104421. no crashes seen .Works as expected.Closing
       Operating System
         Name                        = Mac OS X
         Version                     = 10.14.5
         Architecture                = 64bit
         # CPUs                      = 12
         Memory                      = 17179869184
       Node.js
         Node.js Version             = 10.13.0
         npm Version                 = 6.4.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.2.0.v20190702112137 and  8.1.0.v20190702104421
       Device =Oneplus 5t android 9,Samsung s5 android 6
       Emulator = PIXEL android 9.
       

JSON Source