0

this is a weird one. i have a -pre-compile target in my custom_rules.xml. in here, some JARs get copied into the libs folder.

if i do a clean build, it fails at runtime because those libraries do not get included in the .apk. looking at the output of ant -v ..., Dx is not processing those libs. so, while the project is being compiled against against those libraries, they are not included at the Dx phase.

if i subsequently do a non-clean ant debug, everything is fine, as the JARs copied by -pre-compile were already there at the start of the build.

any ideas what i'm doing wrong?

Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134

1 Answers1

0

i eventually figured this out by painstakingly adding echo statements to the .../tools/ant/build.xml from the SDK.

the path that includes the libraries in .../libs for Dx is defined in the -setup task. this is in the chain before -pre-compile or -pre-build, so if you copy JARs into your .../libs folder at either of those points, it's too late.

i ended up overriding the -setup task, as so,

  <target name="-setup" depends="-prepare-libs, android_rules.-setup"/>

  <target name="-prepare-libs">
    ... build / copy libs in to .../libs here
  </target>

note the syntax for calling through to the overridden -setup task ... the project name defined in the project tag appended with the task name, as defined in the build.xml imported from the SDK.

Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134