To add a library, you just need to make sure that it is passed as an argument when invoking the tool dx.
I use something very similar to the dex target in the Ant template included in the SDK:
<target name="dex" depends="compile">
<echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
<arg value="--output=${intermediate-dex-location}" />
<arg path="${out-classes-location}" />
<fileset dir="${external-libs-folder}" includes="*.jar"/>
</apply>
</target>
<fileset> JAR .
Ant, JAR libs.