3

I'm trying to including the NewRelic library into my project, but I get this error when I build it

Error:Execution failed for task ':v1:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Program Files\Android\android-studio\sdk\build-tools\19.1.0\dx.bat --dex     --output 
    C:\Documents and Settings\t.hart\My Documents\Android\MoneyTracker\v1\build\pre-dexed\debug\android-agent-3.378.0-27125f93a249f513379e837d75ebec255f6dcaa4.jar 
    C:\Documents and Settings\t.hart\.gradle\caches\modules-2\files-2.1\com.newrelic.agent.android\android-agent\3.378.0\1ebf0e20081a7f1b9a5c31bfc4e7dba776e0c171\android-agent-3.378.0.jar
Error Code:
    1
Output:
    Error opening zip file or JAR manifest missing : C:\Documents

To include the library you need to add 3 lines to your build.gradle files,

//This to the buildscript dependancies
classpath 'com.newrelic.agent.android:agent-gradle-plugin:3.378.0'

//This line (in the example it's under the android line
apply plugin: 'newrelic'

//And this to dependancies
compile 'com.newrelic.agent.android:android-agent:3.378.0'

After some trial and error it seems it's the last line (the compile one) that's causing the error to be thrown. Is this because of the spaces in C:/Documents And Settings?

I'm also using these librarys, and they all downloaded to the build/pre-dexed/debug folder fine with no issues.

compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
compile 'com.android.support:support-v4:19.1.0'

EDIT: Updated error message

Error:Execution failed for task ':v1:preDexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Program Files\Android\android-studio\sdk\build-tools\19.1.0\dx.bat --dex --output 
    C:\MoneyTracker\v1\build\pre-dexed\debug\support-v4-19.1.0-cd41ef807caadb29c9df0131dee869d3723185ad.jar 
    C:\Program Files\Android\android-studio\sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar
Error Code:
    1
Output:
    Error opening zip file or JAR manifest missing : C:\Documents

Now that's a strange error...

TMH
  • 6,096
  • 7
  • 51
  • 88

2 Answers2

1

It effectively has to do with spaces in your folders names, the error message tells you gradle can't find a zip or jar manifest in C:\Documents, which is obviously not the folder your newrelic library is in. Try moving your project in a directory which name doesn't have space. Make it a habit, some tools really don't like spaces in filenames (especially unix rooted one).

Mathieu Le Tiec
  • 491
  • 4
  • 9
  • Yes you have to indicate to system where are your gradle files. How you do this depends on how it is now configured. Could you post the content of your PATH environment variable? – Mathieu Le Tiec May 27 '14 at 15:06
  • 1
    It depends on how the tool (here I suppose it's android studio) manages spaces in filenames. By the way, you should have a gradle_home variable set in android studio (probably around sdk/build settings). Just point it to gradle new directory and it should be ok. I'm currently downloading android-studio to see where it is defined and hopefully give you a more precise answer. – Mathieu Le Tiec May 27 '14 at 15:27
  • Great! Windows is often cumbersome when playing with Java, a well configured linux VM will probably save you loads of time. – Mathieu Le Tiec May 27 '14 at 15:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/54542/discussion-between-mathieu-le-tiec-and-tom-hart). – Mathieu Le Tiec May 27 '14 at 15:45
  • OK, look for a .m2 directory in Documents and Settings (maven directory) and a M2_HOME or MAVEN_HOME environment var. I think that's the source of your problem now – Mathieu Le Tiec May 27 '14 at 15:51
  • Sorry I was not able to help you more than that. Good luck! – Mathieu Le Tiec May 27 '14 at 17:14
0

You can set the GRADLE_USER_HOME environment variable, gradle.user.home system property, or --gradle-user-home command line parameter to directory which name doesn't have space.

(via How to change Gradle download location)

Community
  • 1
  • 1
Sergii
  • 1,521
  • 3
  • 24
  • 37