Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16619] Android: LiveView throws errors if action bar is implemented in the app

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-09-10T03:09:36.000+0000
Affected Version/sRelease 3.3.0
Fix Version/sRelease 5.1.0
ComponentsAndroid, LiveView
Labelsmerge-4.1.1, qe-nfc
ReporterLokesh Choudhary
AssigneeFeon Sua Xin Miao
Created2014-03-12T23:10:30.000+0000
Updated2015-10-21T22:40:08.000+0000

Description

NOTE : This is seen on post & pre 3.0 android devices & emulators.

Description:

1. Create a default & replace the app.js with the sample code for action bar from the docs:
var win = Ti.UI.createWindow({
    title: "Old Title",
    navBarHidden: false
});
var actionBar;

win.addEventListener("open", function() {
    if (Ti.Platform.osname === "android") {
        if (! win.activity) {
            Ti.API.error("Can't access action bar on a lightweight window.");
        } else {
            actionBar = win.activity.actionBar;
            if (actionBar) {
                actionBar.backgroundImage = "/bg.png";
                actionBar.title = "New Title";
                actionBar.onHomeIconItemSelected = function() {
                    Ti.API.info("Home icon clicked!");
                };
            }
        }
    }
});

win.open();
2. Build for android device/emulator with live view enabled.

Actual Result:

1. We see following error in console:
[INFO] :   [LiveView] Error Evaluating app.js @ Line: undefined
[ERROR] :  ReferenceError: actionBar is not defined
[ERROR] :  File: app.js
[ERROR] :  Line: undefined
[ERROR] :  SourceId: undefined
[ERROR] :  Backtrace:
[ERROR] :  undefined

Expected Result:

1. We should not see any errors & liveview should work successfully.

Comments

  1. Ingo Muschenetz 2014-05-20

    We'd like to try fixing this for 3.3.0. Possible?
  2. Praveen Innamuri 2014-05-27

    Considering the limited use case (this issue will surface only when a variable is not initialized to any value, even null/undefined and defined only in the higher scope), we can defer it to the future versions - may be, for 3.4.0 release.
  3. Feon Sua Xin Miao 2015-09-09

    PR: https://github.com/appcelerator/liveview/pull/90
  4. Kondal Kolipaka 2015-09-10

    Merged into master.
  5. Lokesh Choudhary 2015-10-21

    Verified the fix. No errors are seen using liveview if action bar is implements in the app. Closing. Environment: Appc Studio : 4.3.3.201510201834 Ti SDK : 5.1.0.v20151020095222 Ti CLI : 5.0.5 Alloy : 1.7.16 MAC Yosemite : 10.10.5 Appc NPM : 4.2.1-5 Appc CLI : 5.1.0-38 Node: v0.10.37 Nexus 5 - Android 6.0 Android Emulator: android 4.4.4, android 4.1.1

JSON Source