Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27188

Android: TabGroup crashes if tab "title" property is not set as of 8.0.2

    Details

    • Story Points:
      5
    • Sprint:
      2019 Sprint 14

      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:

      1. Create a Classic "Default Project".
      2. Set up the project to build with Titanium 8.0.2.GA.
      3. Replace the project's "app.js" with the code below.
      4. 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,
      });
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              andreas.pingas Andreas Pingas
              Reviewer:
              Yordan Banev
              Tester:
              Keerthi Mahalingam (Inactive)
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code