Android Dependency Management Made Easy

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.

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.

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.

4 thoughts on “Android Dependency Management Made Easy

    1. Hi Ricardo,

      I didn’t have any problems installing the plugin or converting the project to maven. It is a library project, the Singly Android SDK that I am working on. But once I converted it to Maven I had classpath issues in both the library and other projects that used it. The example project using the library couldn’t find its own classes and I couldn’t build the library through mvn.

      I tracked some of the issues down to not having the google dependencies in the library project. That enabled me to build it without issues. But I never was able to track down why the example projects couldn’t find the library project.

      To tell the truth though I hadn’t tried building the library as a maven dependency and then putting it into the dependences of the example. I figured as an Android library project it would be picked up by ADT. I also hadn’t looked if my maven version was wrong. In the end I spent a couple hours trying to fix it and then switched to Ivy.

      I am using a new install of Juno on Linux Mint. I have used Maven on other projects and I like it. Would love to know where I went wrong with this.


    1. No it doesn’t handle library projects. Android library projects can’t be distributed as jars unless they just contain source code and not any layouts or other resources. If they library project only contains source code though, no layouts or resources, then it could be distributed as regular jar and not an Android libary and could be included via Ivy.

Comments are closed.