1
votes

When trying to run a project on a Android-phone, Appcelerator gives an error:

[INFO] : Alloy compiled in 6.57967s

[INFO] : Alloy compiler completed successfully

[INFO] : JavaScript files need to be encrypted

[INFO] : Processing JavaScript files

[ERROR] : Failed to parse /Users/bas/Documents/Appcelerator_Studio_Workspace/Whatever-App-master/Resources/android/alloy/controllers/picture-list.js.js

[ERROR] : Invalid left-hand side in assignment expression (21:4)

The stupid thing is that Appcelerator made the file itself:

[INFO] : [picture-list.js.xml] view processing...

[INFO] : style: "picture-list.js.tss"

[INFO] : view: "picture-list.js.xml"

[INFO] : created: "Resources/android/alloy/controllers/picture-list.js.js"

[INFO] : created: "Resources/android/alloy/styles/picture-list.js.js"

... so why make a file and than later on complain about it?

The app is not running now, stops after compiling.

picture-list.js:

function __processArg(obj, key) {
    var arg = null;
    if (obj) {
        arg = obj[key] || null;
        delete obj[key];
    }
    return arg;
}

function Controller() {
    require("/alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
    this.__controllerPath = "complaints/picture-list";
    this.args = arguments[0] || {};
    if (arguments[0]) {
        __processArg(arguments[0], "__parentSymbol");
        __processArg(arguments[0], "$model");
        __processArg(arguments[0], "__itemTemplate");
    }
    var $ = this;
    var exports = {};
    $.__views.pictures = Ti.UI.createTableViewSection({ // line 21
        id: "pictures"
    });
    $.__views.pictures && $.addTopLevelView($.__views.pictures);
    exports.destroy = function() {};
    _.extend($, $.__views);
    _.extend($, exports);
}

var Alloy = require("/alloy"), Backbone = Alloy.Backbone, _ = Alloy._;

module.exports = Controller;

picture-list.js.js:

function __processArg(obj, key) {
    var arg = null;
    if (obj) {
        arg = obj[key] || null;
        delete obj[key];
    }
    return arg;
}

function Controller() {
    require("/alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
    this.__controllerPath = "picture-list.js";
    this.args = arguments[0] || {};
    if (arguments[0]) {
        __processArg(arguments[0], "__parentSymbol");
        __processArg(arguments[0], "$model");
        __processArg(arguments[0], "__itemTemplate");
    }
    var $ = this;
    var exports = {};
    $.__views.picture - list.js = Ti.UI.createView({ // line 21
        id: "picture-list.js"
    });
    $.__views.picture - list.js && $.addTopLevelView($.__views.picture - list.js);
    exports.destroy = function() {};
    _.extend($, $.__views);
    _.extend($, exports);
}

var Alloy = require("/alloy"), Backbone = Alloy.Backbone, _ = Alloy._;

module.exports = Controller;
2

2 Answers

0
votes

Before writing absurd things about a platform which is used by millions of developers, it is always better to know the truth by providing the necessary info.

Titanium has to create JS files first, then it process them for any logical errors.

The info you have provided here is just 50% & your answer cannot be resolved until you share the code of this file picture-list.js.js from your app project, not in Resources. If not possible to share whole code, then it should be fine to share first 40-50 lines of code.

Secondly, I can see duplicated js.js in your files XML, JS, TSS which should not be there.

Lastly, you can just go to this file /Users/bas/Documents/Appcelerator_Studio_Workspace/Whatever-App-master/Resources/android/alloy/controllers/picture-list.js.js & share the line no. 21 here which I guess contains some sort of assignment which is invalid due to some subtle mistakes of yours.

0
votes

Because the compiler lints the JavaScript files, it also validates it.

So what you're seeing is a JavaScript error in the picture-list.js file, I assume line 21.

You can find more information about the error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_assignment_left-hand_side

Edit: Based on your code.

You can see this, (it is invalid JS)

$.__views.picture - list.js = Ti.UI.createView({ // line 21
    id: "picture-list.js"
});

This is probably caused by a - in your original code, or has to do with the name of the controller. - is not supported in names and Id's. I recommend changing it with an underscore, so picture_list.js.

Dashes (-) in javascript are not supported in variables names, thats why this is going wrong!