3

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>
Community
  • 1
  • 1
Infamous911
  • 1,441
  • 2
  • 26
  • 41
  • Can you please show the entire gradle output, not just the error? – OneCricketeer Jun 02 '16 at 15:18
  • How do I do that? Sorry, I am very new to this technology – Infamous911 Jun 02 '16 at 15:20
  • Well, you copied that error, from somewhere, yes? You can [edit] your question with the output that appeared above it as well. – OneCricketeer Jun 02 '16 at 15:22
  • Also, you likely didn't need multidex. People like to suggest that as the magic solution to all gradle errors, but it isn't – OneCricketeer Jun 02 '16 at 15:23
  • For more details about your error and finding a solution you can read this post. http://stackoverflow.com/questions/36698816/gradle-what-is-a-non-zero-exit-value-and-how-do-i-fix-it – OneCricketeer Jun 02 '16 at 15:28
  • Edited. I have tried all the common solutions (building, cleaning, checking for syntax error, various solutions for this specific problem, etc.). – Infamous911 Jun 02 '16 at 15:34
  • Thanks for editing. I still don't see anything that mentions the problem, though. You may read the solution in the previous comment to clean/build & lint your project – OneCricketeer Jun 02 '16 at 15:35
  • The problem is that I am getting the error specified and I don't know how to not get the error specified. I cleaned, built, and linted my project. Nothing of value was obtained (encountered same error after cleaning and building, lint said that I could use the 24.0.0-beta1 version instead of the 23.4.0 version, but saw nothing else wrong with the code). – Infamous911 Jun 02 '16 at 15:41
  • The problem does exist somewhere in your java or xml files. It has to. If all else fails, make a brand new project and immediately try to run it on a device. Start copying over code until you hit the error again – OneCricketeer Jun 02 '16 at 16:47
  • 1
    I created a brand new project and it all works. The project I was testing on before was a brand new project too so I have no idea why that didn't work. Whatever haha thanks for your help! – Infamous911 Jun 02 '16 at 16:57

1 Answers1

1

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)

Hemal Shah
  • 58
  • 6
  • I have already done all of that except for the part regarding attachBaseContext(). When I try to override that method in my MainActivity.java class which extends AppCompatActivity, it says that the @Override tag is an error because it doesn't override any method from the superclass. – Infamous911 Jun 02 '16 at 16:41
  • @Infamous911 you don't put that into the Activity, you would put that into a Application class that extends MultidexApplication, however, as we've seen, you don't need multidex because it isn't solving the issue – OneCricketeer Jun 02 '16 at 16:44
  • Instead of extending Application, extend MultiDexApplication. @cricket_007 You are correct, in general there is no need to use Multidex if there are fewer or no dependency. – Hemal Shah Jun 03 '16 at 17:04