0

I want to build an Android application using ant (as generated by the android tool). The application needs external libraries that are available as .jar. Since other (related) projects need the same libraries, I want to store them in a common place, outside of /libs (let's say "../somewhere/else/something.jar"). The application additionally needs a shared object, which is stored in /libs/armeabi/libSomething.so (it is copied there by ndk-build).

Does anybody know how I must configure my stuff to embed the classes in ../somewhere/else/something.jar into my .APK?

I tried various ways in ant.properties

...
java.compiler.classpath=../somewhere/else/something.jar
jar.libs.dir=libs:../somewhere/else
external.libs.dir=libs:../../ext/android/tomtom

and build.xml

...
<package-helper>
    <extra-jars>
        <jarfile path="../somewhere/else/something.jar" />
    </extra-jars>
</package-helper>
...
<!-- From http://stackoverflow.com/questions/3217643/how-to-add-external-jar-libraries-to-an-android-project-from-the-command-line -->
<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>

None of the above mentioned ways worked... :(

Does anybody have a solution? I am searching and trying now for hours, and I can't imagine that nobody ever had the same problem.

Thanks for any help!!!

  • "I want to build an Android application using ant" -- I would strongly recommend that you move away from Ant and over to Gradle for Android. I expect Ant support to be officially dropped any week now, once Gradle for Android reaches a 1.0 shipping status. Besides, Gradle for Android handles this problem well, either via artifacts pulled from a repository, or from a `compile fileTree()` statement that pulls from your desired location. – CommonsWare Jul 14 '14 at 10:00
  • You are certainly right, and if possible I will follow your recommendation! My problem is, that I have to stick with the build tools of a customer, and I am not sure whether they already support gradle. – Sebastian Vogel Jul 15 '14 at 11:15

0 Answers0