Cordova, getting Error while adding android platform on Ubuntu 14.04

I installed cordova and can create a new project without any problems.

However I'm getting the following error when trying to add android platform:

sudo cordova platform add android
Running platform task...
Adding platform android
Creating android project...

/home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occurred while listing Android targets
    at /home/tushar/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:87:29
    at _rejected (/home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
    at /home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
    at /home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
    at flush (/home/tushar/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)
Error: /home/tushar/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Unable to add platform android. Please see console for more info.

I have tried almost all of the solutions from stackoverflow but none of them solved. I have added the path to android sdk, ant etc on ./bashrc file as following:

export HOME="/home/tushar"
export ANDROID_HOME="$HOME/Development/adt-bundle/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/Development/adt-bundle/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"

export ANT_HOME="$HOME/Development/ant"
export PATH="$PATH:$ANT_HOME/bin"

But I am still getting the problem.

Any Suggestions???

UPDATE

These might be helpful to debug:

$ node -v
v0.10.25

$ npm -v
1.3.10

$ cordova -v
3.5.0-0.2.4

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

There is a problem with your paths: ANDROID_HOME should point to sdk folder, not sdk/tools

Also add ANDROID_TOOLS pointing to sdk/tools

All in all you need: JAVA_HOME, ANT_HOME, ANDROID_HOME, ANDROID_PLATFORM_TOOLS, ANDROID_TOOLS, and maybe ANDROID_SDK_ROOT pointing to sdk as well.

P.S. and without sudo, yes.

I think you don't have to execute "cordova platform add android" as a superuser.

i struggled with the same issue all day.. it turned out i did not add the full path while exporting path variables...

a "shell" hand in our group suggested to run "pwd" to get the "present working directory" and then give export the exact path...it worked

Had the same problem. My PATH was correct. No problems with access rights. Also noted that the adt-emulator was running into an error.

In the end, it was missing libraries to allow the adt (which partially is 32 bit) to run on a 64 bit ubuntu system.

sudo apt-get install lib32z1 lib32z1-dev

resolved this and everything works.

Hope this helps to resolve this issue for other folks.

Had exactly the same problem in LMDE and as answered by Ranunculus, I added the below directly in my terminal and it worked!

export ANDROID_HOME="$HOME/android-sdk-linux"
export ANDROID_TOOLS="$ANDROID_HOME/tools/"
export ANDROID_PLATFORM_TOOLS="$ANDROID_HOME/platform-tools/"
export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
export ANT_HOME="/usr/share/ant"
export PATH="$JAVA_HOME:$ANT_HOME:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS:$PATH"

N.B: Couldnt comment on Ranunculus's answer and so posted it as an answer.

I had the same issue (though running on Windows, but still worth checking on your side) and found out that it was due to a bug in Ant. My Classpath ended with a " too, and I had to fix this by removing the " in my class path variable.

I had the same problem trying hard added multiple configuration which do conflicts and one more thing I found that I had opened multiple terminals when I was updating path on one terminal and trying to execute the Cordova command on another I was still getting the same error so i tried echo $PATH on the first terminal which shows updated path but the other terminal while echoing did not show the updated path so finally I opened new terminal and started again yes this time it works, This kind of problem generally occurs in windows but I am not sure if the same happen on Linux but in my case it was, I hope this may help others newbie now my both Cordova and ionic commands are working fine thanks to the SO community for their support and guidance