I'm attempting to integrate a third party monitoring solution (New Relic) into my Android app, which uses an ant-based build. The integration instructions say to set the ANT_OPTS
environment variable to -javaagent:{path to a jar file}
before executing the ant command to perform the build.
This works swimmingly when I launch my ant build manually from the command line.
However, we also launch ant builds via Jenkins. In the Jenkins build configuration there's a section for configuring your ant builds. In this section is an entry called "Java Options". From searching elsewhere I've gathered this is the place to put JVM arguments. Typically people want to increase the max heap size, etc.
So I put this in the Java Options section:
-javaagent:{path to a jar file}
The Jenkins builds, however, fail during the Android "-dex" target as follows:
[dex] input: /Users/builduser/.jenkins/jobs/Android - Latest/workspace/android/bin/proguard/obfuscated.jar
[dex] [newrelic.info] Detected the New Relic Android agent in an Ant build (/Users/builduser/.jenkins/jobs/Android - Latest/workspace/android/bin/proguard/obfuscated.jar)
[dex] Converting compiled files and external libraries into /Users/builduser/.jenkins/jobs/Android - Latest/workspace/android/bin/classes.dex...
[dx] Unrecognized option: -
[dx] Could not create the Java virtual machine.
I suspect this is not a Google/Android issue because these builds succeed when I set ANT_OPTS and launch the build from a command line. Something about the way Jenkins handles JVM args is screwy and is confusing the Android build tools.
Anybody have a workaround?