Cordova Build Error for Android

prawg picture prawg · Apr 26, 2015 · Viewed 8k times · Source

I have been running through the Cordova tutorial for installation and creating a first app. After spending the last few hours trying to figure this out I have pretty much reached a dead end. I'm currently running Ubuntu and trying to build on Android 4.0.0.

I have all of the files listed in the error below already. In addition to this error I get 3 consecutive popups for non-existent files that say:

"Cannot find file '/home/prawg/workspace/hello/list'"

"Cannot find file '/home/prawg/workspace/hello/targets'"

"Cannot find file '/home/prawg/workspace/hello/--compact'"

Here is the error:

[Error: Please install Android target: "android-22".

Hint: Open the SDK manager by running: /usr/local/bin/android You will require:

  1. "SDK Platform" for android-22
  2. "Android SDK Platform-tools (latest)
  3. "Android SDK Build-tools" (latest)]

ERROR building one of the platforms: Error: /home/prawg/workspace/hello/platforms/android/cordova/build:

Command failed with exit code 2

You may not have the required environment or OS to build this project

Error: /home/prawg/workspace/hello/platforms/android/cordova/build: Command failed with exit code 2

at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)

at ChildProcess.emit (events.js:98:17)

at maybeClose (child_process.js:766:16)

at Process.ChildProcess._handle.onexit (child_process.js:833:5)

Any help on this would be greatly appreciated.

Answer

prawg picture prawg · Apr 27, 2015

So after spending hours trying to figure this out I finally reached a solution.

When I installed Android I did it through the Android Studio download. After installing, I went to the SDK Manger in the UI and updated the 3 files listed in the error above. For some reason this did not update in the SDK where my $ANDROID_HOME path was set to which was /home/prawg/Android/Sdk

The solution is as follows:

I went to the $ANDROID_HOME directory - /home/prawg/Android/Sdk through the terminal and used the following command:

tools/android update sdk --no-ui

From the terminal all of the updates were installed and when I typed the build command for Android there was no issue.

Maybe someone with more Android experience can elaborate on why this is the case?