Search code examples
androidcordovacordova-plugin-proguard

Cordova Android Platform Add Android Error 3.3


So I'm going insane - seems to be endless when it comes to cordova/phonegap.

On Mac OS X mavericks I'm trying to add android as a platform...

So naturally I go...

$ cordova platform add android

I get this error...

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

/Users/jasonstockton/.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/jasonstockton/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:85:29
    at _rejected (/Users/jasonstockton/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
    at /Users/jasonstockton/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/Users/jasonstockton/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/Users/jasonstockton/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
    at /Users/jasonstockton/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
    at flush (/Users/jasonstockton/.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:282:30
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

Before you continue to give me the "you need to add the path" response. I've already done that (hence why I'm losing my mind).

My .bash_profile looks like this...

export PATH=/usr/local/bin:$PATH
export PATH=${PATH}:/Development/adt-bundle-mac/sdk/platform-tools:/Development/adt-bundle-mac/sdk/tools
export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH

Note the second line is for the platform tools. I have tried taking the other items out as well and no luck. I am calling source ~/.bash_profile after each update - also restarted terminal and the computer with no luck.

Just to be cautious I checked the files are all there via terminal just incase the impossible was happening and Finder was lying about the directory. Files all seem to be there...

Jasons-MacBook-Pro:~ jasonstockton$ cd Development/adt-bundle-mac/sdk/platform-tools
Jasons-MacBook-Pro:platform-tools jasonstockton$ ls
NOTICE.txt      adb         api         fastboot        source.properties   systrace
Jasons-MacBook-Pro:platform-tools jasonstockton$ cd 
Jasons-MacBook-Pro:~ jasonstockton$ cd Development/adt-bundle-mac/sdk/tools
Jasons-MacBook-Pro:tools jasonstockton$ ls
Jet         apps            emulator-arm        emulator64-x86      lib         proguard        traceview
NOTICE.txt      ddms            emulator-mips       etc1tool        lint            source.properties   uiautomatorviewer
adb_has_moved.txt   dmtracedump     emulator-x86        hierarchyviewer     mksdcard        sqlite3         zipalign
android         draw9patch      emulator64-arm      hprof-conv      monitor         support
ant         emulator        emulator64-mips     jobb            monkeyrunner        templates

I then kept Googling and found another piece of advice that suggested to update .profile file as well. My .profile file looks like this...

PATH=$PATH:/Development/adt-bundle-mac/sdk/platform-tools:/Development/adt-bundle-mac/sdk/tools
export PATH

Still getting the same error. I tried running the call on other applications and still having trouble.

I read somewhere else to call set to see if it's actually been set... This is what my set path looks like...

PATH=/Applications/MAMP/bin/php/php5.5.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Development/adt-bundle-mac/sdk/platform-tools:/Development/adt-bundle-mac/sdk/tools

If anyone can shed some light on what I may be doing wrong that would be amazing! I'm super lost and confused. The app is all ready for iOS just want to make a version for android. Should be straight forward...

Thanks in advance for your assistance!


Solution

  • I'm extrapolating from other information in your answer but you've added the path

    /Development/adt-bundle-mac/sdk/platform-tools
    

    Later in your command line output you show that you're at "~" and cd to "Development/...". This would imply that the Development folder is in your user folder.

    If it is then the directory you've added to your PATH is incorrect as it is an absolute path that starts at your drive root.

    Try changing the middle line in your bash profile snippet to

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

    or the absolute path including your user folder.

    Restart the bash shell and check that the android command is available by typing "android" in the bash shell.

    You will also want to install Ant and the Java SDK to ensure that your project can be built once the android platform is added.

    Your path to Ant and the location of your Java compiler (javac) will also have to be added to PATH.

    If you use Adobe's PhoneGap distribution of Cordova then you can use the PhoneGap Build cloud service. This will build your app for iOS, Android and Windows without you having to set up any local SDKs specific to these platforms. There is also an restful API available that allows you to invoke build functionality from the command line.