Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14641] Blackberry: Not specifying a "target" throws unhelpful error in CLI

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2014-03-25T18:06:40.000+0000
Affected Version/sRelease 3.1.1
Fix Version/sBacklog
ComponentsBlackBerry
Labelsn/a
ReporterTony Lukasavage
AssigneeRussell McMahon
Created2013-07-24T16:17:12.000+0000
Updated2017-03-09T07:43:04.000+0000

Description

problem

Executing a titanium build without the --target option throws an error that the 99% of developers will have no idea how to work with, seen here:
/usr/local/lib/node_modules/titanium/node_modules/longjohn/dist/longjohn.js:181
        throw e;
              ^
TypeError: Cannot read property '0' of undefined
    at BlackberryNDK.self.build (/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/3.1.1.GA/blackberry/cli/common/blackberryndk.js:233:62)
    at build.<anonymous> (/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/3.1.1.GA/blackberry/cli/commands/_build.js:140:15)
    at /usr/local/lib/node_modules/titanium/lib/cli.js:116:18
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:190:13
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:116:25
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:187:17
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:491:34
    at /usr/local/lib/node_modules/titanium/lib/cli.js:112:8
    at ChildProcess.<anonymous> (/Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/hooks/alloy.js:149:6)
---------------------------------------------
    at /Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/hooks/alloy.js:142:11
    at /usr/local/lib/node_modules/titanium/node_modules/node-appc/lib/async.js:14:6
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:190:13
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:94:25
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:187:17
    at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:459:34
    at /Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/hooks/alloy.js:90:9
    at exithandler (child_process.js:635:7)
It appears it happens because the --target option is not explicitly set.

test case

In any Titanium app, execute the following:
titanium build -p blackberry
and you will get the above error. Just as an additional note, you get the same error if you explicitly define the BB NDK path (-n) and the ip address of the simulator (-A), which should obviously indicate that the target would be "simulator".

expected

There's a few possible solutions, listed in my preferential order:

Make the default target "simulator" like with all other platforms

Do better bounds checking around the line mentioned in the exception. Specifically, the length of the builder.type2variantCpu\[this.builder.target\] array needs to be validated before attempting to access index zero. If the array is empty, an informative error should be thrown, not the current stack trace.

Workaround

Explicitly specify the --target in your command:
titanium build -p blackberry -T simulator -A XXX.XXX.XXX.XXX

Comments

  1. Russell McMahon 2013-08-07

    https://github.com/appcelerator/titanium_mobile_blackberry/pull/151
  2. Pedro Enrique 2013-09-20

    PR no longer valid
  3. Pedro Enrique 2014-02-25

    PR: https://github.com/appcelerator/titanium_mobile_blackberry/pull/205
  4. Lee Morris 2017-03-09

    Closing ticket as fixed.

JSON Source