Tuesday, February 15, 2011

ant 1.8 on ubuntu lucid (10.04)

UPDATE: Note the comment below which points out that you can simply "apt-get install ant1.8".

Trying to build a "Hello, World" app in Android, I built a skeletal project per Developing In Other IDEs page:

android create project \
--target 1 \
--name MyAndroidApp \
--path ./MyAndroidAppProject \
--activity MyAndroidAppActivity \
--package com.example.myandroid

After "apt-get install ant", I tried to build, but got this error:

$ ant debug
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar

Android seems to want the sun version of the JDK, which I had installed earlier, but ant was pointed at the openjdk version. I fixed that error with:

$ export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.22

The next obstacle was:

$ ant debug
Buildfile: build.xml

BUILD FAILED
/home/jholt/android-sdk-linux_x86/asdf/MyAndroidAppProject/build.xml:82: The Android Ant-based build system requires Ant 1.8.0 or later. Current version is 1.7.1

Total time: 0 seconds

The ant 1.8 package from Maverick seems to install just fine. Don't forget the ant-optional package, or else you'll get errors like this:

$ ant build
Invalid implementation version between Ant core and Ant optional tasks.
 core    : 1.8.0 in file:/usr/share/ant/lib/ant.jar
 optional: 1.7.1 in file:/usr/share/ant/lib/ant-nodeps.jar

6 comments:

Anonymous said...

sudo apt-get install ant1.8 - no need to use maverick

Anonymous said...

<3

Anonymous said...

I second that <3

Anonymous said...

The command "sudo apt-get install ant1.8" installs/upgrades the previous ant tool you have. This is the simplest command to install/upgrade ant in ubuntu.

Anonymous said...

thank a lot

Anonymous said...

thank you