RahulOnRails
RahulOnRails

Reputation: 6542

Ubuntu + Error: Failed to run "ant -version", make sure you have ant installed and added to your PATH

In my Ubuntu 12.04, I am trying to install ionic framework but get some error while running the command ionic build android.

I saw a lot of option to set environment variable and got little bit success but even though I am not able to resolve it.

echo $PATH

/usr/bin/node:/home/sainath/.rvm/gems/ruby-1.9.3-p547/bin:/home/sainath/.rvm/gems/ruby-1.9.3-p547@global/bin:/home/sainath/.rvm/rubies/ruby-1.9.3-p547/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/sainath/.rvm/bin:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java:/usr/local/ant/bin:/home/sainath/.rvm/bin:/home/sainath/android/adt-bundle-linux-x86_64-20140702/sdk/platform-tools:/home/sainath/android/adt-bundle-linux-x86_64-20140702/sdk/tools:/home/sainath/.rvm/bin:/home/sainath/android/adt-bundle-linux-x86_64-20140702/sdk/platform-tools:/home/sainath/android/adt-bundle-linux-x86_64-20140702/sdk/tools:/home/sainath/.rvm/bin:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java:/usr/local/ant/bin

At last line, it show ant add to the bashrc file

sudo gedit /etc/bash.bashrc

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
export PATH=$PATH:$JAVA_HOME:${ANT_HOME}/bin

java -version

java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.1) (7u65-2.5.1-4ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

node --version

v0.10.32

New error :-

/home/sainath/android/adt-bundle-linux-x86_64-20140702/sdk/tools/ant/build.xml:698: Execute failed: java.io.IOException: Cannot run program "/home/sainath/android/adt-bundle-linux-x86_64-20140702/sdk/build-tools/android-4.4W/aapt" (in directory "/home/sainath/MobileApps/myFirstIonicApp/platforms/android/CordovaLib"): error=2, No such file or directory

Still get the error. Please suggest some thing .. Thanks in advance.

Upvotes: 0

Views: 8304

Answers (2)

RahulOnRails
RahulOnRails

Reputation: 6542

Atlast after a lot of Googling, Problem resolved.

Command : $sudo gedit /etc/bash.bashrc

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
export PATH=$PATH:$JAVA_HOME:${ANT_HOME}/bin
export PATH=/usr/bin/node:$PATH

Command : source /etc/bash.bashrc to reload the file.

sudo apt-get update
sudo apt-get install ia32-libs
sudo apt-get install libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 libstdc++6:i386 libsdl1.2debian:i386

Now I am able to run command ionic build android

Upvotes: 1

ashoke
ashoke

Reputation: 6461

  • can you try java -version see if java binary is available, if not fix your JAVA_HOME or export the correct path to java binary in PATH

  • make sure sudo apt-get install ia32-libs if you have x64 linux

  • nodejs and ant needs to be on path

Upvotes: 1

Related Questions