2

I'm having a problem builing my project. I constantly run into this build error and I'm pretty sure my JDK implementation is correct. I've read similar problems online to no avail. I get the error:

Error:Execution failed for task ':DriverMagic:dexFlavorEnterpriseDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

My Depencencies in My Gradle file are:

dependencies {

    compile 'com.google.android.gms:play-services:5.+'
    compile 'com.splunk.mint:mint:4.0.3'
    compile 'com.android.support:appcompat-v7:18.0.+'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.newrelic.agent.android:android-agent:3.419.0'

    compile fileTree(dir: 'libs', include: ['*.jar'])
}

The full stack Gradle Console code is:

Executing tasks: [:DriverMagic:assembleFlavorEnterpriseDebug]

Configuration on demand is an incubating feature.

Setting up signingConfigs...
----------------------------

computed version name: 2.0.1e
computed version name: 2.0.1
:DriverMagic:preBuild UP-TO-DATE
:DriverMagic:preFlavorEnterpriseDebugBuild UP-TO-DATE
:DriverMagic:compileFlavorEnterpriseDebugNdk UP-TO-DATE
:DriverMagic:checkFlavorEnterpriseDebugManifest
:DriverMagic:preFlavorEnterpriseReleaseBuild UP-TO-DATE
:DriverMagic:preFlavorPlayStoreDebugBuild UP-TO-DATE
:DriverMagic:preFlavorPlayStoreReleaseBuild UP-TO-DATE
:DriverMagic:prepareComAndroidSupportAppcompatV71800Library UP-TO-DATE
:DriverMagic:prepareComGoogleAndroidGmsPlayServices5089Library UP-TO-DATE
:DriverMagic:prepareFlavorEnterpriseDebugDependencies
:DriverMagic:compileFlavorEnterpriseDebugAidl UP-TO-DATE
:DriverMagic:compileFlavorEnterpriseDebugRenderscript UP-TO-DATE
:DriverMagic:generateFlavorEnterpriseDebugBuildConfig UP-TO-DATE
:DriverMagic:generateFlavorEnterpriseDebugAssets UP-TO-DATE
:DriverMagic:mergeFlavorEnterpriseDebugAssets UP-TO-DATE
:DriverMagic:generateFlavorEnterpriseDebugResValues UP-TO-DATE
:DriverMagic:generateFlavorEnterpriseDebugResources UP-TO-DATE
:DriverMagic:mergeFlavorEnterpriseDebugResources UP-TO-DATE
:DriverMagic:processFlavorEnterpriseDebugManifest UP-TO-DATE
:DriverMagic:processFlavorEnterpriseDebugResources UP-TO-DATE
:DriverMagic:generateFlavorEnterpriseDebugSources UP-TO-DATE
:DriverMagic:compileFlavorEnterpriseDebugJava UP-TO-DATE
:DriverMagic:preDexFlavorEnterpriseDebug UP-TO-DATE
:DriverMagic:dexFlavorEnterpriseDebug
AGPBI: {"kind":"SIMPLE","text":"objc[5651]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.","position":{},"original":"objc[5651]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined."}
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536","position":{},"original":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)","position":{},"original":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)","position":{},"original":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':DriverMagic:dexFlavorEnterpriseDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.526 secs
Ben Akin
  • 167
  • 2
  • 15
  • Some dependencies use com.android.support that version different yours. compile 'android.support:android-support-v4:$version' is conflict with compile 'com.android.support:appcompat-v7:18.0.+' – jerry Mar 12 '15 at 06:27

2 Answers2

2

The answer is in your Gradle Console:

Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined."

It doesn't know which one of them should use - remove one and the problem should be solved.

mrek
  • 1,655
  • 1
  • 21
  • 34
  • I was wondering if I need to delete the file java on the library. Another thing, I can't find the Home/jre. – Kairi San Nov 16 '15 at 07:10
  • You can [find](http://stackoverflow.com/a/4531639/3894977) it using `System.getProperty("java.home")`. – mrek Nov 16 '15 at 11:29
  • I have deleted the file but the same error still exist. Is there any other way to solve this? – Kairi San Nov 17 '15 at 04:23
  • You shouldn't delete the file, you should remove gradle dependency. The problem is, that you are importing one class (JavaLaunchHelper) from two packages and gradle doesn't know which one should import. I have no idea what else you can do but you were probably changing your gradle file recently and that change caused this error. – mrek Nov 17 '15 at 09:09
0

If You have already updated your SDK and You also using google-play-services then you need to take care of the dependency because there are some kind of conflics with :

Follow the below : compile 'com.google.android.gms:play-services:+' Replace by compile 'com.google.android.gms:play-services:6.5.87'

Note: Here '6.5.87' is the google-play-service version. I hope it will help..

Maddy Sharma
  • 4,870
  • 2
  • 34
  • 40