I was looking for a really easy way to do dependency managment for my Android apps where I could still use Eclipse and ADT. I wanted to be able to specify a dependency and have that jar and any of its dependency jars available in the Android project and built into the final app. I also wanted to be able to use the Eclipse ADT tools as normal to build and launch apps. I tried setting up the maven android plugin but had issues with getting that working. I found a much easier approach using Ivy and Ant.
First I put in an ant build.xml that uses Ivy. Notice I am having the binaries downloaded directly into the libs folder of the Android project.
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="your-project-name" default="resolve"> <target name="resolve" description="retrieve dependencies with ivy"> <ivy:retrieve conf="binaries" pattern="libs/[artifact](-[classifier]).[ext]" /> </target> <target name="clean" description="clean ivy cache"> <ivy:cleancache /> </target> </project>
Then I have the ivy.xml file where I specify all of my dependencies. In this case I am importing commons-lang but I could have many dependencies specified. Any of dependencies of those dependencies will also be downloaded.
<ivy-module version="2.0"> <info organisation="com.your.project" module="your-module" /> <configurations> <conf name="binaries" description="binary jars" /> </configurations> <dependencies> <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="binaries->default" /> </dependencies> </ivy-module>
And finally on the command line in the root of the Android project I run a simple command. You could also have right-clicked on the build.xml file inside of eclipse and do Run As -> Ant Build.
This runs ant which in turn uses Ivy to download dependencies. All dependencies are downloaded directly into the libs folder of the Android project just as if I had downloaded them manually and put them there. Everything else with the ADT and Eclipse works exactly the same. If I ever need to clean out jars from the libs directory I can just delete them and then rerun the resolve command. You could extend Ant and Ivy if you wanted to do something more complex, but for me this is all I need.
Easy dependency management for Android apps.