Build Error Process Finished with non-zero exit value 2 in Android Studio (gradle)

Asked 2 years ago, Updated 2 years ago, 118 views

I'm having trouble getting a build error on Android Studio.
Windows 7 java version "1.8.0_40"
Android Studio 1.1.0

Error: Execution failed for task':app:dexDebug'.
    >com.android.ide.common.process.ProcessException: org.gradle.process.internal.Exception:
    Process 'command' C:\java\bin\java.exe' 'finished with non-zero exit value 2

I just created the project, but I didn't write any specific code, but when I added the jar reference, I got an error.

apply plugin: 'com.android.application'

    android{android{
    compileSdkVersion21
    buildToolsVersion "21.1.2"
            defaultConfig {
            applicationId "com.example.isopon.testrpc"
            minSdkVersion17
            targetSdkVersion21
            versionCode1
            versionName "1.0"
    }
    buildTypes {
        release {
            miniEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compilefileTree (include: ['*.jar'], dir: 'libs')
        compile'com.android.support:appcompat-v7:21.0.3'
        compile files ('libs/javassist.jar')
        compile files ('libs/netty-3.2.1.Final.jar')
        compile files ('libs/msgpack-0.6.6.jar')
        compile files ('libs/msgpack-rpc-0.7.0.jar')
        compile files ('libs/slf4j-api-1.6.1.jar')
        compile files ('libs/slf4j-log4j12-1.6.4.jar')
        compile files ('libs/slf4j-simple-1.6.1.jar')
    }

I'm in trouble because I don't know the cause.
May I ask for your advice?

android android-studio

2022-09-30 20:36

2 Answers

The jar file group under libs is
compilefileTree(include:['*.jar'], dir:'libs')
You can include everything in the description in .

Therefore, all compile files('libs/○○.jar') are no longer required.


2022-09-30 20:36

The same thing happened in my environment, and I will describe how I handled it.

I did not know the detailed error in the build from Android Studio, so I ran gradle directly on the command line.

bash<ANDROID_STUDIO_HOME>/gradle/gradle-<version>/bin/gradle:app:dexDebug

(In case of Windows, you will be running gradle.bat in the same directory.)

This command also fails, but an exception is printed in addition to the error display on Android Studio.
This exception message was able to determine the cause.

In my case, the reason was that different libraries contained classes with the same name.

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define L;
    atcom.android.dx.merge.DexMerger.readSortableTypes (DexMerger.java:596)
    atcom.android.dx.merge.DexMerger.getSortedTypes (DexMerger.java:554)
    atcom.android.dx.merge.DexMerger.mergeClassDefs (DexMerger.java:535)
    atcom.android.dx.merge.DexMerger.mergeDex(DexMerger.java:171)
    atcom.android.dx.merge.DexMerger.merge (DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers (Main.java:454)
    at com.android.dx.command.decker.Main.runMonoDex (Main.java:303)
    at com.android.dx.command.decer.Main.run (Main.java:246)
    at com.android.dx.command.decer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)

:app:dexDebug FAILED

FAILURE—Build failed with an exception.

* What was wrong:
Execution failed for task ':app:dexDebug'.
>com.android.ide.common.process.processException: org.gradle.process.internal.Exception: Process 'command'/usr/lib/jvm/java-8-oracle/bin/java' 'finished with non-zero exit value 2


2022-09-30 20:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.