我在构建项目时遇到了问题。我经常遇到这个构建错误,我很确定我的JDK实现是正确的。我在网上看到类似的问题无济于事。我收到错误:
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
我的Gradle文件中的Depencencies是:
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'])
}
完整堆栈Gradle控制台代码为:
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
答案 0 :(得分:2)
答案在您的Gradle控制台中:
类JavaLaunchHelper在两者中实现 /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java 和 /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib。 将使用两者之一。哪一个未定义。“
它不知道应该使用哪一个 - 删除一个,问题应该解决。
答案 1 :(得分:0)
如果您已经更新了SDK并且还使用了google-play-services,那么您需要处理依赖关系,因为存在某种冲突:
按照以下说明: 编译com.google.android.gms:play-services:+' 更换 通过编译com.google.android.gms:play-services:6.5.87'
注意:这里' 6.5.87'是google-play-service版本。 我希望它会有所帮助..