[android] Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease'

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

The answer is


Just add a "multidex-config.txt" in you app directory:

enter image description here


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


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
}

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

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 22
    multiDexEnabled = true
}

In DefaultConfig Add multiDexEnabled = true

    defaultConfig {
    applicationId "com.test"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled = true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

I know this is an old question, but I spent a couple of days looking through solutions which didn't work for me so maybe this helps someone else.

My project had a plugin which was throwing an error. I had to remove the plugin and add it again, and suddenly I could make it through the build process.

$ cordova add phonegap-plugin-push
$ cordova plugin add phonegap-plugin-push

I just ran the above and it was solved.


Add multiDexEnabled true in your defaultConfig in the app level gradle.

defaultConfig {
    applicationId "your application id"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

I had the similar problem in my app. Here is what I did.

1.add this for build.gradle in module: app

multiDexEnabled = true

So the code would be like:

    android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example..."
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

This worked for me. Hope this helps you too :)

In the same project I was using Firebase too. So enabling multiDexEnabled let to another problem in Firebase for Pre Lollipop devices. Some FireBase classes were not identified. (Unable to get provider com.google.firebase.provider).
Method to resolve that is explained here.


  1. Remove the jar files in your gradle
  2. Sync it
  3. Copy that jar and sync it

This worked for me.


For those who still use VS-TACO and have this issue. This happens due to version inconsistency of a jar files.

You still need to add corrections to build.gradle file in platforms\android folder:

 defaultConfig {
        multiDexEnabled true 
 }

 dependencies {
      compile 'com.android.support:multidex:1.0.3'
 }

It's better to do in build-extras.gradle file (which automatically linked to build.gradle file) with all your other changes if there are, and delete all in platforms/android folder, but leave there only build-extras.gradle file. Then just compile.


I fixed mine I added to my project > app > libs android volley.jar and my problem was solved


I disabled the Zip Align Enabled option here

I am having random issues with the latest AndroidStudio (3.2 B1) and tried all the solutions above. I got it working by disabling the "Zip Align Enabled" option in "Build Types"


By default, Android Studio has a maximum heap size of 1280MB. If you are working on a large project, or your system has a lot of RAM, you can improve performance by increasing the maximum heap size for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon.

If you use a 64-bit system that has at least 5 GB of RAM, you can also adjust the heap sizes for your project manually. To do so, follow these steps:

Click File > Settings from the menu bar (or Android Studio > Preferences on macOS). Click Appearance & Behavior > System Settings > Memory Settings.

For more Info click

https://developer.android.com/studio/intro/studio-config

enter image description here


I had the same problem. One day the program was working perfectly, and the following wasn't. I checked on Github the changes I made. For me the problem was on build.gradle (Module:app) in the dependencies:

compile 'com.android.tools.build:gradle:2.1.2'

This line was the one that was causing the problem. After changing it the app was running properly again


If you're facing the problem after updating the google play services 9.8.0 add this to your dependencies :

`dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.google.firebase:firebase-crash:9.8.0'
compile 'com.google.maps.android:android-maps-utils:0.4.4'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'

}

Well, I believe the question is answered and has already been accepted. But I am going to write what I faced and how I solved it.

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

I wasn't fortunate to apply all the settings and got success. But when I tried to Debug the project again. This time I got Three Error (including above):

Error:Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.

and

Error:Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=

So what I did? I just go to Android Studio:

File > Invalidate Caches / Restart.. > Invalidate & Restart

Quick Fix!

Extra Note:

What I found in Gradle Console:

:app:incrementalDebugTasks :app:prePackageMarkerForDebug :app:fastDeployDebugExtractor :app:generateDebugInstantRunAppInfo :app:transformClassesWithDexForDebug To run dex in process, the Gradle daemon needs a larger heap. It currently has approximately 910 MB. For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties. For more information see https://docs.gradle.org/current/userguide/build_environment.html :app:transformClassesWithDexForDebug FAILED

Read More about it Here on Oracle Blog


I got this error When upgrading Google play services to 9.0 from 7.5

Having error with below one:

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

When I changed to

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

There is no error. Try this


I really don't know how but the bug gone after I done all this:

1

delete implementation 'com.google.android.gms:play-services:12.0.1'

And add

implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services-places:12.0.1'

2

Update git, jdk, change JDK location in Project structure

3

Delete the build folder in my Project

4

Clean and rebuild the Project


just setting the multiDexEnabled to true worked fine.

    defaultConfig 
    {
        multiDexEnabled true     
    }

Sol 1: In build.gradle:

defaultConfig {
    multiDexEnabled true
}

Clean your project and rebuild.

Sol 2: in local.properties add,

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

Sol 3

compile 'com.android.support:multidex:1.0.1'

Else add all 3 in your application.


For me, this turned out to be an unimplemented parcelable class with no datatype [Any]; due to which there was a TODO() constructor created in parcelable implementation of model class.

Hope it helps someone.

@SerializedName("firstTxnDetails")
var firstTxnDetails: Any? = Any()

//in parcelable implementation :

constructor(parcel: Parcel) : this(
            parcel.readInt(),
            parcel.readLong(),
            parcel.readInt(),
            parcel.readDouble(),
            parcel.readLong(),
            TODO("firstTxnDetails"), // -> correct this
            parcel.readString(),
            parcel.readLong(),
            parcel.readParcelable(MasterSavingPlan::class.java.classLoader),
            parcel.readInt(),
            parcel.readString(),
            parcel.readString()) {
    }

The best way comes from James Riordan's answer from this thread

This can be fixed by updating to Gradle 5.5

The easiest way to do this is to update the wrapper in use:

  • Open gradle/gradle-wrapper.properties

  • Find the line that looks like

distributionUrl=https\://services.gradle.org/distributions/gradle-5.X.X-all.zip
  • Change the version to 5.5-all.zip

Then try running the build again.


After updating to Android 3.4, I started to get the error, tried all the above solutions.

Root cause of the problem was, updating Android Studio enabled the Instant Run.

Hence, one of the solutions you can try is Disabling Instant Run, if its enabled for you, fixed my problem.


I've updated jdk to 1.8.0_74, Android-studio to 2.1 preview 1 and add to Application file

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

So, mine didn't get resolved by adding the multiDexEnabled flag. It actually was there before getting the error message.

What resolved the error for me was making sure I was using the same version of all play-services libraries. In one library I had 11.8.0 but in the app that consumes the library I was using 11.6.0 and that difference was what caused the error message.

So, instead of changing your libraries to a specific version like previous answers, maybe you wanna check you're using the same version all across since mixing versions is explicitly discouraged by Android Studio by warnings.


I know it's a bit of an old question, but still. Everytime this happens to me, it's because I've included all of the play-services libraries. Just change play-services:x.x.x to play-service-:x.x.x in the build.gradle(module) file


In my case after invalidate cache and restart the android studio fixed the problem .To do that go to

File -> invalidate cache / Restart


Just Change the google play services in gradle (module app) from 9.x.x to the lower version 8.4.0 is work for me


I have just written this code into gradle.properties and it is ok now

org.gradle.jvmargs=-XX:MaxHeapSize\=2048m -Xmx2048m

None of these answers worked for me. I am using Android studio 3.4.1.

I was able to build the project but Android studio showing this error when I was going to deploy it to mobile device. It turns out it is "instant runs" fault.

Follow this answer: https://stackoverflow.com/a/42695197/3197467


You can fix this issue by adding a project ext property googlePlayServicesVersion to app/App_Resources/Android/app.gradle file like this:

project.ext {
    googlePlayServicesVersion = "+"
}

It worked to me only using a specific service.

For example instead of use:

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

I used:

com.google.android.gms:play-services-places:10.0.1


This happened to me even on debug builds and just cleared all the module level and project level build folders and it worked, yeah just like that.


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.


add this line in your build.gradle

 defaultConfig {
    ............
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
    compileOptions.encoding = 'ISO-8859-1'
    multiDexEnabled true
}

After lots of effort I just added below credential and I succeed

1) app-> 'proguard-rules.pro' file

-ignorewarnings

-keep class * {
    public private *;
}

2) And also added in app -> build.gradle file

android {

        ...........................
    defaultConfig {
        ..................  

     multiDexEnabled true
    }


    buildTypes {
        debug {
            minifyEnabled true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
        innerTest {
            matchingFallbacks = ['debug', 'release']
        }

    }

...................................................
}

dependencies {
    ..................................
    implementation  'com.android.support:multidex:1.0.2'
}

Add this line to ProGuard-rules.pro file:

-keepparameternames

That helped me while obfuscating library. I was getting zip exception when I add library as dependency.


DEPRECATED

gradle.properties

# ...
android.enableD8.desugaring = true
android.enableIncrementalDesugaring = false

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-gradle-plugin

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries Invoke-customs are only supported starting with android 0 --min-api 26 error: resource android:attr/fontVariationSettings not found Exception : AAPT2 error: check logs for details Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)

Examples related to gradlew

Gradle: Could not determine java version from '11.0.2' Difference between using gradlew and gradle Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease' Difference between clean, gradlew clean Could not find or load main class org.gradle.wrapper.GradleWrapperMain How/when to generate Gradle wrapper files? Android Studio: Plugin with id 'android-library' not found gradlew: Permission Denied