Wednesday, September 9, 2026

Building Apache Cordova on Ubuntu 14.04

I was receiving the number of errors trying to build Apache Cordova project for Android platform. The main issue was due to ussage the following construct in bash script "create"

# we do not want the script to silently fail
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap on_error ERR
trap on_exit EXIT

it shows the error of next executed command but not the original one that produced the error.

For example it showed the error:

An unexpected error occurred: [ ! -e "$BUILD_PATH"/framework/libs/commons-codec-1.7.jar ] exited with 1


But originally the problem was with previous command:
$ android update project --target 17 --path /home/joseph/android-sdk-linux_x86/cordova/cordova-android/framework

Because of incorrect target platform inserted here.

It just exatract the maximum possible platform available out of your android SDK with the following command:
$ android list targets | grep id: | tail -1 | cut -f 2 -d ' '



So in order to build the project successsfully you should run
$ android list targets
and make sure you have the platform you need in the list


After removal of all the junk my target looked like:

$ android list targets
Available Android targets:
----------
id: 1 or "android-17"
     Name: Android 4.2
     Type: Platform
     API level: 17
     Revision: 1
     Skins: WVGA800 (default), HVGA, WXGA800-7in, WQVGA400, WVGA854, QVGA, WQVGA432, WXGA720, WSVGA, WXGA800
     ABIs : armeabi-v7a, mips


OK, now I was able run build but it still throwed an errors.

I tried to build cordova manually by entering the frameworks directory

$ cd ./framework
$ android update project -p . -t android-17
$ ant jar

sudo update-alternatives --config java


JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre/
./bin/create /home/joseph/workspace/RoadTripCosts com.ChervoneMobile.RoadTripCosts RoadTripCosts

No comments:

Post a Comment