Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24367] Android: Going back to the tabgroup with android back button crashes app with "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object ti.modules.titanium.ui.TabGroupProxy.getProperty(java.lang.String)"

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-02-24T02:16:50.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsqe-6.1.0
ReporterLokesh Choudhary
AssigneeGary Mathews
Created2017-02-02T01:40:16.000+0000
Updated2017-02-24T18:42:39.000+0000

Description

This issue is probably due to TIMOB-24253.

Steps to reproduce:

1. Use the code below in your app.js.
var win1 = Ti.UI.createWindow({
    backgroundColor: 'blue',
    title: 'Blue'
});

var lbl = Ti.UI.createLabel({text: 'I am a blue window.'});

lbl.addEventListener('click', function(){
	Ti.UI.createWindow().open();	
});

win1.add(lbl);

var win2 = Ti.UI.createWindow({
    backgroundColor: 'red',
    title: 'Red'
});

win2.add(Ti.UI.createLabel({text: 'I am a red window.'}));

var tab1 = Ti.UI.createTab({
    window: win1,
    title: 'Blue'
}),
tab2 = Ti.UI.createTab({
    window: win2,
    title: 'Red'
}),
tabGroup = Ti.UI.createTabGroup({
    tabs: [tab1, tab2]
});
tabGroup.open();
2. Build for android device/emulator. 3. After the app launches click on I am blue window label. 4. A new window opens up. 5. Hit the android back button to close the window to return to the tab group.

Actual results:

1. The app crashes with error:
[ERROR] :  TiApplication: (main) [8300,8300] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.timob24253/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object ti.modules.titanium.ui.TabGroupProxy.getProperty(java.lang.String)' on a null object reference; Titanium 6.1.0,2017/01/31 13:23,undefined
[ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.timob24253/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object ti.modules.titanium.ui.TabGroupProxy.getProperty(java.lang.String)' on a null object reference
[ERROR] :  TiApplication: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.-wrap11(ActivityThread.java)
[ERROR] :  TiApplication: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
[ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:148)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
[ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
[ERROR] :  TiApplication: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object ti.modules.titanium.ui.TabGroupProxy.getProperty(java.lang.String)' on a null object reference
[ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTabGroup.addTab(TiUIActionBarTabGroup.java:338)
[ERROR] :  TiApplication: 	at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:396)
[ERROR] :  TiApplication: 	at ti.modules.titanium.ui.TabGroupProxy.windowCreated(TabGroupProxy.java:371)
[ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:33)
[ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:559)
[ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:673)
[ERROR] :  TiApplication: 	at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:21)
[ERROR] :  TiApplication: 	at android.app.Activity.performCreate(Activity.java:6251)
[ERROR] :  TiApplication: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
[ERROR] :  TiApplication: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
[ERROR] :  TiApplication: 	... 9 more

Expected results:

1. We should be able to return to the tabgroup with out a crash.

Comments

  1. Lokesh Choudhary 2017-02-08

    [~gmathews], One more weird thing is I see the issue only on Nexus 6 - 6.0.1. Tried it on Google pixel - 7.1.1, Nexus 5 - 6.0.1 & emulator - 6.0 & I could not reproduce it.
  2. Gary Mathews 2017-02-09

    master: https://github.com/appcelerator/titanium_mobile/pull/8822
  3. Lee Morris 2017-02-24

    Can verify this fix. Tested with the following environment; Android 7.1.1 (Nexus 6P) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.1.0.v20170223182720 Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source