0

With respect to this question, simply putting a jar into the /libs does not auto-magically include that jar into the .dex when invoking, say, ant debug. Not at least with Android SDK ver 15.

I've verified this by comparing the same project created two different ways. First (call it 'Alpha'), by Eclipse. Second, via android create project ..., blah blah blah (the Ant way, call it 'Bravo').

Both Alpha and Bravo I built using ant debug. Comparing their /bin dirs, the jar under <project_root>/libs is missing from Bravo's *.d; Alpha's aren't.

What magic is Eclipse embedding during project creation?

Better still, how can I ensure a jar is passed to ant debug|release when building a project, that a jar is included in the endstate?

Community
  • 1
  • 1
Steven
  • 2,789
  • 2
  • 18
  • 12
  • I was able to get it in the endstate by adding a `.classpath` with the jar listed (this was missing obviously from Bravo's layout) but I was hoping to do this via command-line switch; hence, why this post is a comment and not an answer. – Steven Apr 08 '12 at 01:25

1 Answers1

1

You may just have to adjust the build.xml to include something like the following in the -pre-build node if you want to hardwire it in. You can also add this in a custom target in the build.xml file that would able you do include from the command line when you want. Something like the following could work.

<target name="add-jar">
    <copy file="${src.folder}/YourJarHere.jar" tofile="libs/YourJarHere.jar" overwrite="true"/>
</target>

Where ${src.folder} is defined in your ant.properties file.

Something like src.folder=PATHOFYOURJAR

Then you should be able to run

ant debug add-jar

including the file.

I have had to manually create the libs folder in the past but I don't see why you can't do this through the build.xml file. Hope this helps!

Rymnel
  • 4,515
  • 3
  • 27
  • 28
  • Thanks, Rymnel. For now I've `touch`-ed and `echo`-ed generating the `.classpath`. I was mildly surprised that `.classpath` works but then Android development tends to be Eclipse-friendly. Part of my reqs is not modifying/contributing to Ant artifacts (running it via Gradle). Still, can't find fault with your approach. Gonna leave the question open for another day. If nothing else comes up, I'm selecting your answer. – Steven Apr 08 '12 at 18:31