简体   繁体   English

通过jenkins将jvm参数传递给ant混淆了android构建工具

[英]Passing jvm argument to ant via jenkins confuses android build tools

I'm attempting to integrate a third party monitoring solution (New Relic) into my Android app, which uses an ant-based build. 我试图将第三方监视解决方案(New Relic)集成到我的Android应用程序中,该应用程序使用基于蚂蚁的构建。 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. 集成说明说要在执行ant命令执行构建之前将ANT_OPTS环境变量设置为-javaagent:{path to a jar file}

This works swimmingly when I launch my ant build manually from the command line. 当我从命令行手动启动我的ant构建时,此方法可以正常工作。

However, we also launch ant builds via Jenkins. 但是,我们也通过詹金斯(Jenkins)启动了蚂蚁构建。 In the Jenkins build configuration there's a section for configuring your ant builds. 在Jenkins构建配置中,有一个部分用于配置您的ant构建。 In this section is an entry called "Java Options". 在本节中,有一个名为“ Java选项”的条目。 From searching elsewhere I've gathered this is the place to put JVM arguments. 通过搜索其他地方,我已经收集了放置JVM参数的地方。 Typically people want to increase the max heap size, etc. 通常,人们希望增加最大堆大小等。

So I put this in the Java Options section: 因此,我将其放在“ Java选项”部分中:

-javaagent:{path to a jar file}

The Jenkins builds, however, fail during the Android "-dex" target as follows: 但是,Jenkins构建在Android“ -dex”目标期间失败,如下所示:

  [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. 我怀疑这不是Google / Android问题,因为当我设置ANT_OPTS并从命令行启动构建时,这些构建成功。 Something about the way Jenkins handles JVM args is screwy and is confusing the Android build tools. Jenkins处理JVM args的方式有些棘手,并且混淆了Android构建工具。

Anybody have a workaround? 有人有解决方法吗?

It looks like this is only an issue when the job name contains a space (" "). 作业名称中包含空格(“”)时,这似乎只是一个问题。 And then only when "-javaagent:{jar}" is specified as a "Java Option" in the ant plugin section. 然后,只有在ant插件部分中将“ -javaagent:{jar}”指定为“ Java Option”时才可以。 I cloned my job and used a name without a space and the build succeeded. 我克隆了我的工作,并使用没有空格的名称,构建成功。 Still unsure if this is an issue with the Jenkins ant plugin or with Google's "dx" executable, but now I'm leaning toward the latter. 仍然不确定这是Jenkins ant插件还是Google的“ dx”可执行文件存在问题,但是现在我倾向于后者。

This may be a conflict with Proguard, While this Proguard section is on the New Relic documentation site, it's not in the install instructions within the New Relic user interface :/ 这可能与Proguard发生冲突,尽管此Proguard部分位于New Relic文档站点上,但不在New Relic用户界面内的安装说明中:/

1) Add a New Relic exclusion to your app by adding this to your proguard.cfg file: 1)将新遗物排除项添加到您的应用中,方法是将其添加到您的proguard.cfg文件中:

-keep class com.newrelic.** { *; }
-dontwarn com.newrelic.**
-keepattributes Exceptions, Signature, InnerClasses

2) Clean your project, and then run your app in an emulator or device to start seeing data. 2)清理您的项目,然后在模拟器或设备中运行您的应用程序以开始查看数据。

Link to the doc in question. 链接到相关文档。 I'm working on revamping the docs and help-text for New Relic since a number of Proguard conflicts have cropped up recently. 由于最近出现了许多Proguard冲突,因此我正在为New Relic修改文档和帮助文本。

If it keeps failing, get in touch with Support at support.newrelic.com and we can investigate. 如果仍然失败,请通过support.newrelic.com与支持部门联系,我们可以进行调查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM