[TIMOB-27188] Android: TabGroup crashes if tab "title" property is not set as of 8.0.2
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-07-02T22:09:22.000+0000 |
Affected Version/s | Release 8.0.2 |
Fix Version/s | Release 8.1.0 |
Components | Android |
Labels | TabGroup, android, engSchedule, regression, tab, title |
Reporter | Andreas Pingas |
Assignee | Joshua Quick |
Created | 2019-06-26T21:28:59.000+0000 |
Updated | 2019-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,
});
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...
PR (master): https://github.com/appcelerator/titanium_mobile/pull/11001
thanks :)
Thanks for reporting this [~andreas.pingas]. We've added a unit test to help make sure this issue never happens again.
PR (8.1.x): https://github.com/appcelerator/titanium_mobile/pull/11004
FR Passed.Waiting on Jenkins
Merged to 8_1_X, waiting on build against master to merge that PR...
Verified the fix on sdk 8.2.0.v20190702112137 and 8.1.0.v20190702104421. no crashes seen .Works as expected.Closing