I experience problems when trying to build my Android project which depends on New Relic. See grade command and stack trace below.
Command:
./gradlew clean assembleProdDebug assembleProdDebugTest
See terminal output below:
...
:my-project:my-project:packageReleaseJniLibs[newrelic] Error encountered while loading the New Relic agent
java.io.IOException: File exists
at sun.tools.attach.BsdVirtualMachine.createAttachFile(Native Method)
at sun.tools.attach.BsdVirtualMachine.<init>(BsdVirtualMachine.java:74)
at sun.tools.attach.BsdAttachProvider.attachVirtualMachine(BsdAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
at com.sun.tools.attach.VirtualMachine$attach.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.newrelic.agent.android.NewRelicTask.injectAgent(NewRelicTask.groovy:45)
at com.newrelic.agent.android.NewRelicTask$injectAgent$0.callCurrent(Unknown Source)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':my-project:newRelicInstrumentTask'.
> java.io.IOException: File exists
It complains about "File exists" but it doesn't say anything about what file or where or how to solve it.
Top level build.gradle file has the following dependency:
classpath "com.newrelic.agent.android:agent-gradle-plugin:4.+"
and each of the two apps has the following:
compile 'com.newrelic.agent.android:android-agent:4.273.4'
New Relic and the build process worked perfectly fine until I merged two apps into the same Android studio project. I did this because the two apps share a lot of code with each other.
Anyone experienced the same problem? Any ideas on how to solve it? Just ask if you need more information.