Error execution for task ': app: transformClassesWithDexForDebug' - Gradle?

I did not want to start a new question related to this problem, since I know that there are some of them, but I still have not found a solution, and I'm pretty stuck.

I am currently getting the error message:

Error: execution completed for task ': app: transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command' / Library / Java / JavaVirtualMachines / jdk1. 7.0_79.jdk / Contents / Main / bin / java '' completed with nonzero output value 2

And this is what the Gradle showi console is

UNCERTAINT TOP EXCEPTION LEVEL: com.android.dex.DexException: several dex files define Lbolts / AggregateException; at com.android.dx.merge.DexMerger.readSortableTypes (DexMerger.javaโˆ—79) at com.android.dx.merge.DexMerger.getSortedTypes (DexMerger.java UP35) at com.android.dx.merge.DexMerger.mergeClassDefs (DexMerger.java//17) at com.android.dx.merge.DexMerger.mergeDexes (DexMerger.java:164) at com.android.dx.merge.DexMerger.merge (DexMerger.java:188) at com.android. dx.command.dexer.Main.mergeLibraryDexBuffers (Main.java:504) at com.android.dx.command.dexer.Main.runMonoDex (Main.java data34) at com.android.dx.command.dexer.Main. run (Main.java:277) at com.android.dx.command.dexer.Main.main (Main.java:245) at com.android.dx.command.Main.main (Main.java:106)

FAILED

FAILURE: build failed with exception.

  • What went wrong: Execution completed for task ': app: transformClassesWithDexForDebug'.

    com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: process command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk / Contents / Home / bin / java '"completed with nonzero exit value 2

  • Try it: run with the -stacktrace option to get a stack trace. Run with the -info or --debug option to get more log output.

STRICTLY MALFUNCTIONAL

This is my build.gradle:

apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.andrewnwalker.mousetimes_california" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.parse.bolts:bolts-android:1.+' compile fileTree(dir: 'libs', include: ['Parse-*.jar']) compile files('libs/Parse-1.12.0.jar') compile files('libs/bolts-tasks-1.3.0.jar') compile files('libs/universal-image-loader-1.9.5.jar') compile files('libs/joda-time-2.9.1.jar') } 

I tried all the obvious things like cleaning, rebuilding, opening / closing. I also tried removing some of the dependencies to see if that would change.

As far as I know, I did not change anything when I worked fine. I am sure that I just ran the project for the second time in a row and an error occurred. Maybe I'm wrong.

Anyone have any suggestions?

+1
source share
2 answers

I recently ran into the same problem, and here is my two-step solution:

  • Top Gradle Level:

     // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha3' classpath 'com.google.gms:google-services:2.0.0-alpha3'//for any google libs } } allprojects { repositories { jcenter() } } 
  • Gradle module (application) level:

     apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "your_app_id" minSdkVersion 9 targetSdkVersion 22 // Enabling multidex support can also help (uncomment and test) //multiDexEnabled true } buildTypes { release { //minifyEnabled true //shrinkResources true proguardFiles 'proguard-project.txt' } } } dependencies { //your dependencies } apply plugin: 'com.google.gms.google-services' **//Place this line at the end if you use any google service lib.** 
+1
source

Update your top level gradle as follows:

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0-alpha3' classpath 'com.google.gms:google-services:2.0.0-alpha3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 

Update your gradle application level as follows:

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { // package name, target sdk and version code as per your code multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { incremental true javaMaxHeapSize "4g" } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') // your libraries here compile 'com.google.android.gms:play-services:8.4.0' compile 'com.android.support:multidex:1.0.1' } apply plugin: 'com.google.gms.google-services' 

And update your Android manifest file this way

 <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:name="android.support.multidex.MultiDexApplication" android:theme="@style/AppTheme"> 

And add this line to your launch activity in the onCreate function.

 MultiDex.install(this); 

See if this works.

0
source

Source: https://habr.com/ru/post/1274459/


All Articles