I\'m trying to build an Android project that has some dependencies. The jar files are in the lib/ directory. I can build the project by adding those jar file to my classpa
Answering my own question:
I created a file "build.properties" and added the line
external.libs.dir=lib
It was a lucky guess, really.
put jars in ${YOUR_PROJECT}/libs
directory
Just for future reference: Right now there is a bug in the SDK which prevents of using jar.libs.dir: http://code.google.com/p/android/issues/detail?id=33194
A simple solution to use jar.libs.dir again (while waiting for the bug to get fixed), is to add this target in the build.xml file:
<target name="-pre-compile">
<path id="project.all.jars.path">
<path path="${toString:project.all.jars.path}"/>
<fileset dir="${jar.libs.dir}">
<include name="*.jar"/>
</fileset>
</path>
</target>
Jay K's answer was right at the time of writing, but now the SDK has changed, and here is the new way to do it:
Add the following line to ant.properties
:
jar.libs.dir=lib
Tested, works where external.libs.dir does not work.
That changed in December 2010 and then again in October 2011.
The example above dosen't quite work right. You cannot overwrite the project.all.jars.path inline. Following is a working example :
<target name="-pre-compile">
<!-- HACK to add the android-support-v4.jar to the classpath directly from the SDK -->
<echo>ORIGINAL jars.path : ${toString:project.all.jars.path}</echo>
<path id="project.all.jars.path.hacked">
<path path="${toString:project.all.jars.path}"/>
<path path="${sdk.dir}/extras/android/support/v4/android-support-v4.jar"/>
</path>
<path id="project.all.jars.path">
<path path="${toString:project.all.jars.path.hacked}"/>
</path>
<echo>HACKED jars.path : ${toString:project.all.jars.path}</echo>
</target>
The jar.libs.dir
property is a single directory. It's not like a CLASSPATH which is a colon/semicolon separated list. The way to have multiple directories in your jar.libs.dir is to not set it directly; let it default to libs
and go to libs and create the required soft links to .jar files you need.