Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease'

485,023

Solution 1

For me, the problem was solved after I removed jar file from my project. it seems that one of the jar files inside my project was using an older version of google play services.

Solution 2

i fixed it just this code.

local.properties

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m

and you should do this changing on gradle

defaultConfig {
    applicationId "yourProjectPackage"
    minSdkVersion 15
    versionCode 1
    versionName "1.0"
    targetSdkVersion 23

    multiDexEnabled true //important
}

Solution 3

If you make multiDexEnabled = true in defaultConfig of the app, you will get the desired result.

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 22
    multiDexEnabled = true
}

Solution 4

I did receive also the same error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 1

well I fixed this with help of following steps:

  1. Open your app's build.gradle (not the one in the project root) and add:

    android {
    //snippet
    //add this into your existing 'android' block
    
        dexOptions {
        javaMaxHeapSize "4g"
        }
    
    //snip
    }
    
  2. Try your build again.

Note: 4g is 4 Gigabytes and this is a maximum heap size for dex operation.

Solution 5

NO NEED FOR MULTIDEX, I REPEAT, NO NEEED FOR MULTIDEX


Let me elaborate: Multidex is basically a tool that comes with Android, and if you set it to true, apps with >64,000 methods are able to compile using a slightly altered build process. However you only need to use multidex if your error looks like this:

trouble writing output: Too many field references: 131000; max is 65536. You may try using --multi-dex option.

or like this

Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

But that is not the case here! The problem here (for me atleast) is being caused by your build.gradle file's dependencies.

THE SOLUTION: Utilize specific dependencies—don't just import an entire section of dependencies!

For example, if you need the Play Services dependency for location, only import it for location.

DO:

compile 'com.google.android.gms:play-services-location:11.0.4'

DON'T:

compile 'com.google.android.gms:play-services'

Another issue that could be causing this may be some sort of external library you are using, that is referencing a prior version of your dependency. Follow these steps in that case:

  1. Go to SDK manager, and install any updates to your dependencies
  2. Make sure that your build.gradle file shows the latest version. To get the latest version, use this link: https://developers.google.com/android/guides/setup
  3. Edit your library (or install an updated version if that exists), to reference the latest version

I know this question is old, but I need to get this answer out there, because using multidex for no reason could potentially cause ANR's for your app! ONLY use multidex if you're sure you need it, and you understand what it is.

I myself spent hours trying to resolve this issue without multidex, and I just wanted to share my findings—hope this helps

Share:
485,023

Related videos on Youtube

Sheraz Ahmad Khilji
Author by

Sheraz Ahmad Khilji

I am an Android Developer and android can be a pain in the ass but what can i say, It's tough love so there will always be hurdles. So don't worry if you face those hurdles because i am here to help you overcome them. So Lets Get on with it \m/_

Updated on August 24, 2022

Comments

  • Sheraz Ahmad Khilji
    Sheraz Ahmad Khilji almost 2 years

    The Problem is that i am able to run my app when i change to debug mode but it fails when i switch to release mode.

    Exception:

    **FAILURE: Build failed with an exception.**
    > Execution failed for task ':app:transformClassesWithDexForRelease'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
    

    When i ran the gradle build command with stacktrace then this is what i get

    ./gradlew app:transformClassesWithDexForRelease --stacktrace
    
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
    
    *Exception is:*
    
    >org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForRelease'.
                at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
                at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
                at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
                at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
                at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
                at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
                at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
                at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
                at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
                at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
                at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
                at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
                at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
                at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
                at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
                at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
                at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
                at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
                at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
                at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
                at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
                at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
                at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
                at org.gradle.internal.Factories$1.create(Factories.java:22)
                at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
                at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
                at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
                at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
                at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
                at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
                at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
                at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
                at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
                at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
                at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
                at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
                at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
                at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
                at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
                at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
                at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
                at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
                at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
                at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
                at org.gradle.util.Swapper.swap(Swapper.java:38)
                at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
                at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
                at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
                at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
                at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
                at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
                at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
                at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
        Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
                at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:54)
                at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:57)
                at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
                at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)
                at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
                at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
                at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
                at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
                at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
                at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
                at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
                ... 68 more
        Caused by: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
                at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:422)
                at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:178)
                at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:174)
                at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
                ... 77 more
        Caused by: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
                at com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1472)
                at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1389)
                at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:250)
                ... 80 more
        Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
                at com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1456)
                ... 82 more
        Caused by: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
                at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:43)
                at com.android.builder.core.AndroidBuilder$2.call(AndroidBuilder.java:1464)
                at com.android.builder.core.AndroidBuilder$2.call(AndroidBuilder.java:1456)
        Caused by: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
                at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
                at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:41)
                ... 2 more
    

    I am using

    • Android Studio 2.0 Beta 6
    • Java version: Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
    • Gradle Version: com.android.tools.build:gradle:2.0.0-beta6
    • And i have Multidex enabled

    My build.gradle file

    apply plugin: 'com.android.application'
    apply plugin: 'com.getkeepsafe.dexcount'
    
    android {
    
        def VERSION_CODE = 52
        def VERSION_NAME = "1.0"
        compileSdkVersion 23
        buildToolsVersion '23.0.2'
    
        defaultConfig {
            applicationId "com.example.app"
            manifestPlaceholders = [appName: "Personal App"]
            minSdkVersion 14
            targetSdkVersion 23
            renderscriptTargetApi 19
            renderscriptSupportModeEnabled true
            versionCode VERSION_CODE
            versionName VERSION_NAME
    
            // Enabling multidex support.
            multiDexEnabled true
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
            encoding = 'UTF-8'
        }
    
        signingConfigs {
            livekeystore {
                storeFile file('../key.jks')
                keyAlias 'livekeystore'
                keyPassword '123asd'
                storePassword '123asd'
            }
        }
    
    
        buildTypes {
            release {
                minifyEnabled true
                shrinkResources true
                zipAlignEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                signingConfig signingConfigs.burgerking
    
                manifestPlaceholders = [googleMapsKey: "@string/release_google_map_key", appNameSuffix: ""]
            }
    
            debug {
                applicationIdSuffix '.dev'
                debuggable true
                minifyEnabled false
                shrinkResources false
                zipAlignEnabled false
    
                manifestPlaceholders = [googleMapsKey: "@string/debug_google_map_key", appNameSuffix: ' (Dev-' + VERSION_CODE + ')']
    
            }
        }
    
        dexOptions {
            incremental true
            javaMaxHeapSize "4g" // 2g should be also OK
        }
    
        useLibrary 'org.apache.http.legacy'
    
    }
    
    repositories {
        maven { url 'https://mint.splunk.com/gradle/' }
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
    }
    
    buildscript {
        repositories {
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.2'
            classpath 'com.newrelic.agent.android:agent-gradle-plugin:4.244.0'
        }
    }
    
    
    dependencies {
        compile 'com.google.code.gson:gson:2.4'
        compile 'com.android.support:appcompat-v7:23.2.0'
        compile 'com.android.support:recyclerview-v7:23.2.0'
        compile 'com.android.support:cardview-v7:23.2.0'
        compile 'com.android.support:design:23.2.0'
        compile 'com.android.support:multidex:1.0.1'
        compile 'com.google.android.gms:play-services-base:8.4.0'
        compile 'com.google.android.gms:play-services-location:8.4.0'
        compile 'com.google.android.gms:play-services-analytics:8.4.0'
        compile 'com.google.android.gms:play-services-maps:8.4.0'
        compile 'com.google.android.gms:play-services-ads:8.4.0'
        compile 'com.googlecode.libphonenumber:libphonenumber:7.0.5'
        compile 'com.facebook.android:facebook-android-sdk:4.1.1'
        compile 'de.greenrobot:eventbus:2.4.0'
        compile 'com.viewpagerindicator:library:2.4.1@aar'
        compile 'com.nineoldandroids:library:2.4.0'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.squareup:pollexor:2.0.2'
        compile 'com.makeramen:roundedimageview:2.1.0'
        compile 'com.mcxiaoke.volley:library:1.0.16@aar'
        compile files('libs/now-auth-api.jar')
        compile 'com.jakewharton:butterknife:5.1.2'
        compile 'com.github.ksoichiro:android-observablescrollview:1.2.0'
        compile 'io.card:android-sdk:5.3.0'
        compile 'com.appboy:android-sdk-ui:1.10.3'
        testCompile 'junit:junit:4.11'
        testCompile('org.mockito:mockito-core:1.9.5') {
            exclude group: 'org.hamcrest'
        }
        testCompile('org.powermock:powermock-module-junit4:1.5') {
            exclude group: 'org.hamcrest'
        }
        testCompile('org.powermock:powermock-api-mockito:1.6.2') {
            exclude group: 'org.hamcrest'
        }
    
        compile 'me.grantland:autofittextview:0.2.1'
    
    }
    

    It seems i am able to get my release build working if i remove minifyEnabled true from it. Why is that, is there another way to solve it

    • Harisewak
      Harisewak about 8 years
      could you post your app's build.gradle file?
    • Sheraz Ahmad Khilji
      Sheraz Ahmad Khilji about 8 years
      @Harisewak i have updated the question, Please take a look at it now
    • Harisewak
      Harisewak about 8 years
      Yes @Sheraz you are right that switching minifyEnabled to false solves the issue. I read this in doc : 'you have to enable minifyEnabled in order to turn on code shrinking, and then shrinkResources to turn on resource shrinking. If you have not already been using minifyEnabled, make sure you get that working before also adding shrinkResources, since you may have to edit your proguard-rules.pro file to make sure any methods you access with reflection etc are listed as keep rules in that file' (tools.android.com/tech-docs/new-build-system/resource-shrin‌​king). See if this is the case.
    • Sheraz Ahmad Khilji
      Sheraz Ahmad Khilji about 8 years
      @Harisewak it still doesnt solve the problem if i run the task with debug then i get this error Uncaught translation error: com.android.dx.cf.code.SimException: com.android.dx.rop.cst.CstMethodRef cannot be cast to com.android.dx.rop.cst.CstInterfaceMethodRef
    • Santacrab
      Santacrab about 8 years
      I have the same problem with my project. If I use the com.android.tools.build:gradle:1.3.0, I'm able to compile. As soon as I use the 2.0.0 it gives me the same problem
    • PavelGP
      PavelGP over 6 years
      I had the same issue because my project has duplicated libraries, external classes which are duplicate classes from android framework. For example I had QName.class (and other too) in library xpp3_min-1.1.4c which are duplicate class from android-26 library. To avoid this issue please follow the link: stackoverflow.com/questions/30648172/…
    • Naveen
      Naveen almost 6 years
      minifyEnable true gives me exception - Below is my Question, stackoverflow.com/questions/51720018/… Please help me with this.
    • Underdog
      Underdog about 2 years
      got same problem and I just rm -rf .gradle and it works
  • jai_b
    jai_b almost 8 years
    thanks i have changed the version to compile 'com.google.android.gms:play-services:8.4.0' i think volley uses some old Google play services which are not compatible with play-services:>9.0
  • Alexeev Valeriy
    Alexeev Valeriy almost 8 years
    same issue with jackrabbit-standalone-2.12.2.jar. If I add it to project then the issue raises.
  • Ryan H.
    Ryan H. over 7 years
    This was the solution for me. The problem is that several third-party modules reference play-services with different versions so how is it expected that these versions are going to be in sync all the time? Very weird architectural detail.
  • parvus
    parvus over 7 years
    @MikeOx I updated some Android tools, and as a result I ended up with two versions of a few jar files, e.g. mockable-android-24.jar and mockable-android-25.jar. Removing the older ones fixed these build errors for me.
  • Ulysses Alves
    Ulysses Alves over 7 years
    "local.properties" is that a file name or a configuration value? Where (eg: in which folder) is it located inside the project?
  • aemre
    aemre over 7 years
    The local.properties file goes in the project's root level. if you have a problem about multiDex--> developer.android.com/studio/build/multidex.html
  • hdotluna
    hdotluna over 7 years
    Saved my day! Cheers!
  • Mr. Mad
    Mr. Mad over 7 years
    but i am not using any jar file then why i am facing this problem
  • Ajay Pandya
    Ajay Pandya over 7 years
    Not Working Any Other chance>
  • Ivan Milisavljevic
    Ivan Milisavljevic over 7 years
    Can you please provide more details explanation for this solution
  • Marcelo Gumiero
    Marcelo Gumiero over 7 years
    I just inserted multiDexEnabled true in my build.gradle and the magic was done. Thank you.
  • OneCricketeer
    OneCricketeer over 7 years
    Which "line" did you add here?
  • OneCricketeer
    OneCricketeer over 7 years
    You didn't need a JAR file. compile 'com.android.volley:volley:1.0.0' developer.android.com/training/volley/index.html
  • OneCricketeer
    OneCricketeer over 7 years
    This is a sign that all the other Google Play Services version that you use do not match.
  • OneCricketeer
    OneCricketeer over 7 years
    Your should not use this. Please selectively compile those libraries. developers.google.com/android/guides/setup#split
  • OneCricketeer
    OneCricketeer over 7 years
    @IvanMilisavljevic You can use Gradle now, not JAR files. developers.google.com/android/guides/setup#split
  • OneCricketeer
    OneCricketeer over 7 years
    That is not the only step to allowing Multidex. And you only need it when you see a DexException, anyway. developer.android.com/studio/build/multidex.html
  • DaveNOTDavid
    DaveNOTDavid about 7 years
    I don't know what all of this means, but it worked for me!
  • Sukhbir
    Sukhbir about 7 years
    Same here. I solved the problem by replacing compile 'com.google.android.gms:play-services:10.2.0' with compile 'com.google.android.gms:play-services-location:10.2.0'
  • Ruchir Baronia
    Ruchir Baronia almost 7 years
    Changing it to what?
  • Sara Alberola
    Sara Alberola almost 7 years
    I erased it (I was checking it now) and it kept working
  • Miha_x64
    Miha_x64 almost 7 years
    On API <21, multiDexEnabled without extending Application class from MultiDexApplication will lead to NoClassDefFoundErrors.
  • stoefln
    stoefln over 6 years
    Brilliant! Works perfectly!
  • Ciberman
    Ciberman over 6 years
    How do you know which specific dependency causes the problem? I have added com.facebook.android:audience-network-sdk:4.+ and I cannot build since then.
  • Kathir
    Kathir over 6 years
    Thanks a lot. Never would have taught of this.
  • MbaiMburu
    MbaiMburu over 6 years
    The best...I've been roaming around for hours..thanks!
  • Rowan
    Rowan over 6 years
    You saved my day!
  • WillC
    WillC about 6 years
    Worked for me just now.
  • Naveen
    Naveen almost 6 years
    minifyEnable true gives me exception - Below is my Question, stackoverflow.com/questions/51720018/… Please help me with this.
  • HendraWD
    HendraWD over 5 years
    Can you be more specific which jar files? Is it the jar files inside our project gradle/wrapper?
  • html_programmer
    html_programmer over 5 years
    Don't know what it is with people mentioning "the jars". That doesn't explain anything.
  • user155
    user155 about 5 years
    such a stupid answer. if you have a lot of dependencies you will need multi dex anyway. just add kotlin libraries, a couple of google services (com.google.android.gms:play-services-*:*) , firebase services, crashlytics, gson, androidx (support libraries), cardview, recyclerview, android.material:material. IT'S NOT POSSIBLE WITHOUT MULTI DEX (do you like capslock? I don't, so please don't answer such questions here next time...)
  • Oleg Dater
    Oleg Dater about 5 years
    org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m fixed for me, thanks!
  • Fogh
    Fogh about 5 years
    I had the same issue. Disabling Instant Run and enabling it again worked for me.
  • Simon Hutton
    Simon Hutton about 5 years
    Fixed my issue too. Mind you - Instant Run is useful so I hope there's a better fix soon
  • devDeejay
    devDeejay about 5 years
    Yes absolutely its useful! Hope there is a fix soon! @SimonH
  • Oliver Dixon
    Oliver Dixon about 5 years
    Aaaaarg they always enable this on the update and it always causes so many issues.
  • Starwave
    Starwave about 5 years
    Jep, this was the cause of the problem for me too after putting Firebase in the project, disabling Instant Run finally lets me build it, thanks!
  • wesley franks
    wesley franks almost 5 years
    Disabling Instant run worked for me with this issue. Didn't get the error again.
  • Hossein
    Hossein over 4 years
    Some body is clever here! Exactly !, its not multidex error, multidex error is different, and it can be from some of dependencies. and @user155, RUCHIR IS NOT RESPONSIBLE FOR YOUR DEPENDENCIES PROBLEM!and i like capslocks :)
  • Shashwat Gupta
    Shashwat Gupta almost 4 years
    where to change ....above changes ? can you please tell me the file name ?