Infamous911
Infamous911

Reputation: 1531

Android - Execution failed for task ':app:transformClassesWithMultidexlistForDebug'

When I attempt to run my very simple android application I get the following output:

Information:Gradle: Executing tasks: [:app:assembleDebug]

Information:Kotlin: Kotlin JPS plugin is disabled Information:6/2/16, 11:25 AM - Compilation completed with 1 error and 0 warnings in 6s 706ms

Error:Gradle: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

I had originally not been using multidex and I was getting a similar error with the standard dex. Here is the original output I was getting without multidex:

Information:Gradle: Executing tasks: [:app:assembleDebug]

Information:Kotlin: Kotlin JPS plugin is disabled Information:6/2/16, 11:28 AM - Compilation completed with 1 error and 0 warnings in 7s 624ms

Error:Gradle: Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

I think I've tried every conceivable solution and nothing works.

Here is my application level build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0 rc4"

    defaultConfig {
        applicationId "com.example.XXX.testapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
//        debug {
//            minifyEnabled true
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        incremental = true;
        javaMaxHeapSize "4g"
        //preDexLibraries = false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
}

I have tried running with various combinations of lines commented and uncommented as you can see, to no avail.

I have no files in my "lib" folder.

Here is my higher-level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And here is my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.XXX.testapplication">

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:name="android.support.multidex.MultiDexApplication"
            android:theme="@style/AppTheme">
        <activity
                android:name=".MainActivity"
                android:label="@string/app_name"
                android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

Upvotes: 3

Views: 6454

Answers (1)

Hemal Shah
Hemal Shah

Reputation: 58

If you are going to integrate multidex support then you need to do that in a apprehensive manner. From this link

Try doing the following changes:

Add multiDexEnabled true to your gradle file in the defaultConfig closure.

In your manifest add the MultiDexApplication class from the support library as follows:`

<application
    ...
    android:name="android.support.multidex.MultiDexApplication">
    ...
</application>

`

Also note that, if you are already having an Application class for your project, override the method called attachBaseContext() and in that method call: MultiDex.install(this)

Upvotes: 1

Related Questions