4

I tried to add the android platform by:

$ cordova platform add android

I get that out:

    Creating android project...

/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occured during creation of android sub-project. 

/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
    at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:85:29
    at _rejected (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
    at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
    at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
    at flush (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

    at /usr/local/lib/node_modules/cordova/src/platform.js:244:30
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

I specified the SDK's path in the .bash_profile, is there something more I need to do?

Thanks for answers!

tafelrunde
  • 128
  • 2
  • 13

4 Answers4

6

I fixed it!! First you have to add android tools and platform tools to your PATH...

So open your user profile ( in terminal type:)

nano ~/.profile
PATH=$PATH:/YOUR_ADT_FOLDER/sdk/platform-tools:/YOUR_ADT_FOLDER/sdk/tools
export PATH

Save it and type on terminal:

. ~/.profile

Now try to add your cordova platform, if it not works try to install apache ant. I'm using elementary os, so I opened the software center, searched for ant e install it. After it see if 'ant' is on your terminal and then add your platform.

Carlos Porta
  • 1,224
  • 5
  • 19
  • 31
  • can you help for windows? – Teoman shipahi Feb 05 '14 at 05:12
  • I did this and still ge tthe same error. export HOME="/Users/rover" export ANDROID_HOME="$HOME/Documents/Dev/Android/adt-bundle-mac-x86_64-20140702/sdk" export ANDROID_PLATFORM_TOOLS="$ANDROID_HOME/platform-tools" export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$ANDROID_HOME/build-tools:$PATH" export ANT_HOME="/usr/local/bin/ant" #export PATH="$PATH:$ANT_HOME/bin" $ which ant /usr/local/bin/ant $ ls /usr/local/bin/ant /usr/local/bin/ant $ ant -v Apache Ant(TM) version 1.9.4 $ cordova --version 4.0.0 error is: node_modules/q/q.js:126 throw e; – mylord Nov 06 '14 at 15:19
  • @mylord Did you restart your CLI? – B.K. Dec 13 '14 at 23:20
  • @B.K. I solved that here: http://stackoverflow.com/questions/26783594/phonegap-cordova-build-android-node-modules-q-q-js-throw-e – mylord Dec 14 '14 at 16:02
0

For OSX your path needs to include /Users/yourusername

their example: /Development/adt-bundle/sdk/platform-tools
needs to be: /Users/yourusername/Development/adt-bundle/sdk/platform-tools

check your path with echo $PATH (use caps, it's case sensitive!)

K00kykelly
  • 31
  • 3
0

this is documentation Phonegab docs for setup .bash_profile(mac),bashrc(linux), or windows

and my .bash_profile:

export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools

visit the solution here

I hope this helps you

Community
  • 1
  • 1
ikhsannetwork
  • 103
  • 2
  • 6
-1

Try,

cordova platform add android
Dawson Loudon
  • 6,029
  • 2
  • 27
  • 31