Ebenezer Scrooge
Ebenezer Scrooge

Reputation: 21

Cordova "add platform android" results in "An error occured" and no explanation

folks. Here I share a pain in the ass. I installed Cordova on Windows 7. It creates a new project properly on cordova create X Y Z but the command cordova platform add android fails. And it does not fail as described in earlier threads by others... it simply does not tell why it fails.

I've gone through all the solutions recommended earlier. That includes:

But it still fails to add anything to the project. The message is the following:

Error: An error occured during creation of android sub-project.

   at C:\Users\username\AppData\Roaming\npm\node_modules\cordova\src\platform.js:250:30
   at ChildProcess.exithandler (child_process.js:651:7)
   at ChildProcess.EventEmitter.emit (events.js:98:17)
   at maybeClose (child_process.js:753:16)
   at Process.ChildProcess._handle.onexit (child_process.js:820:5)

Anyone got an idea what the heck is it missing?

For more information, here is what actually happens before this error message shows up.

cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Checking Android requirements...
Running "android list target" (output to follow)
Available Android targets:
----------
id: 1 or "android-14"
     Name: Android 4.0
     Type: Platform
     API level: 14
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800
 Tag/ABIs : no ABIs.
----------
id: 2 or "android-15"
     Name: Android 4.0.3
     Type: Platform
     API level: 15
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800
 Tag/ABIs : no ABIs.
----------
id: 3 or "android-16"
     Name: Android 4.1.2
     Type: Platform
     API level: 16
     Revision: 4
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/armeabi-v7a
----------
id: 4 or "android-17"
     Name: Android 4.2.2
     Type: Platform
     API level: 17
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/armeabi-v7a, default/mips, default/x86
----------
id: 5 or "android-18"
     Name: Android 4.3
     Type: Platform
     API level: 18
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/armeabi-v7a
----------
id: 6 or "android-19"
     Name: Android 4.4.2
     Type: Platform
     API level: 19
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/armeabi-v7a
----------
id: 7 or "Google Inc.:Google APIs:17"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 3
     Description: Android + Google APIs
     Based on Android 4.2.2 (API level 17)
     Libraries:
      * com.google.android.media.effects (effects.jar)
          Collection of video effects
      * com.android.future.usb.accessory (usb.jar)
          API for USB Accessories
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: WXGA800, WVGA854, WQVGA400, QVGA, WXGA800-7in, WSVGA, HVGA, WXGA720, WVGA800 (default), WQVGA432
 Tag/ABIs : default/armeabi-v7a

Running "android update project -p "C:\Users\tomcat\.cordova\lib\android\cordova\3.2.0\framework" -t android-17" (output to follow)...
Updated project.properties
Updated local.properties
build.xml: Found version-tag: custom. File will not be updated.
Updated file C:\Users\tomcat\.cordova\lib\android\cordova\3.2.0\framework\proguard-project.txt

Creating android project...
Running bin/create for platform "android" with command: ""C:\Users\tomcat\.cordova\lib\android\cordova\3.2.0\bin\create"  "c:\Cordova\HelloWorld\platforms\android" "com.helloworld.pixeldog" "HelloWorld"" (output to follow)

Upvotes: 0

Views: 718

Answers (1)

Deep Mehta
Deep Mehta

Reputation: 1280

Run the "android" command from your adt\sdk\tools folder and install the latest Tools and SDK. Also make sure your PATH has the right variables.

For this you will need ANT to be installed , a JAVA JDK and an Android SDK installed

JAVA_HOME (C:\Program Files\Java\jdk)

ANT_HOME ({ant location}\apache\apache-ant)

ANDROID_HOME ({android sdk location}\android-sdk)

Add these to your PATH variable like %ANT_HOME%/bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin

Close and re-open your cmd and run your command again.

Upvotes: 1

Related Questions