6

I'm working with Android at the moment, trying to avoid using Eclipse (for which I have an irrational hatred).

I need to include an external .jar file (used in my Activity)and have no idea how to link it for ant debug...

I've read up on build.xml files but adding <path id="compiler.classpath">...</...> or <classpath> nodes to the XML doesn't help fix it.

Hope someone can help me out!

connec
  • 7,231
  • 3
  • 23
  • 26

1 Answers1

7

Just put it in the libs/ directory. Everything else is taken care of from there -- no Ant script modifications are needed. For example, here is a sample project showing integrating a BeanShell interpreter this way.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 2
    So how is this solved when we don't want to put a copy of the same jar in each of our projects and instead want to use it from a common directory? – icecream Mar 15 '11 at 13:13
  • @icecream: If you are using Ant, you can create an Android library project that contains the JAR and other stuff, then use that Android library project in your other projects. There are indications that this might not work well for the combination of Android library projects and Eclipse, though I have not experienced the problems there first-hand and so have limited information. – CommonsWare Mar 15 '11 at 14:11
  • 1
    Ok. I formulated the comment above into a question and got an answer. It turned out that the way to solve this particular problem was to override jar.libs.dir in build.properties to point out the relative path of my common libs directory. Seems to work so far. http://stackoverflow.com/questions/5312478/how-do-i-reference-external-jar-files-in-a-common-directory-not-libs-to-build-a – icecream Mar 15 '11 at 15:42