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
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 }
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
.
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:
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 }
Try your build again.
Note: 4g is 4 Gigabytes and this is a maximum heap size for dex operation.
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:
- Go to SDK manager, and install any updates to your dependencies
- 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
- 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 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.
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 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
Well, I believe the question is answered and being accepted. But I am going to wrote what I face 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
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.
- Remove the jar files in your gradle
- Sync it
- Copy that jar and sync it
This worked for me.
I have just written this code into gradle.properties and it is ok now
org.gradle.jvmargs=-XX:MaxHeapSize\=2048m -Xmx2048m
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
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
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.
just setting the multiDexEnabled to true worked fine.
defaultConfig { multiDexEnabled true }
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); }
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
add this line in your build.gradle
defaultConfig { ............ aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false compileOptions.encoding = 'ISO-8859-1' 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" }
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 fixed mine I added to my project > app > libs android volley.jar and my problem was solved
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' }
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.
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.
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
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
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.
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' }
来源:https://stackoverflow.com/questions/35890257/android-errorexecution-failed-for-task-apptransformclasseswithdexforrelease