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

0

I'm getting this error each time I try to give rebuild project

  

Error: 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: Error while executing     java process with main class com.android.dx.command.Main with     arguments {--dex --num-threads = 4 --output     C: \ Users \ M \ Documents \ MY_APP_NAME \ app \ build \ media \ transforms \ dex \ release \ folders \ 1000 \ 1f \ main     C: \ Users \ M \ Documents \ MY_APP_NAME \ app \ build \ intermediate \ transforms \ proguard \ release \ jars \ 3 \ 1f \ main.jar}   

My build.gradle is this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "MY_PACKAGE"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 8
        versionName "5.2"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.google.android.gms:play-services-ads:11.0.1'
    compile 'com.google.android.gms:play-services-location:11.0.1'
}

OBS - this occurs in the debug version tb. I'm already freaking out !!! Someone knows what to do ...

Thank you.

EDITED

Now it's popping up that comes with this task:

  

: app: transformClassesWithDexBuilderForDebug

(last task that appears in the Gradle Console)

and no Messages appears:

  

Information: Gradle tasks [: app: generateDebugSources,   : app: generateDebugAndroidTestSources,: app: mockableAndroidJar]   Error: Failed to complete Gradle execution.

     

Cause: An existing connection was terminated by the host   remote

I tried to upgrade my gralde.build to the latest versions of the tools, but nothing tb.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "MY_PACKAGE"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 8
        versionName "5.2"
        multiDexEnabled true
    }

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

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.android.support:multidex:1.0.2'
    compile project(':adcolony-sdk-3.1.2')
    compile 'com.squareup.picasso:picasso:2.5.2' //for Inmobi
}

add in Android Manifets the multiDex tag, but nothing tb.

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

Funny that my app is already published (to try to update only), this only started to happen in this new version of Android Studio (3.0.1), q alias ends with PC RAM !!! I tried to uninstall this version and install the old one, but then tb error appears.

Does anyone know how to solve the problem? Thank you.

    
asked by anonymous 02.02.2018 / 13:32

1 answer

0

About the error

Your app is probably over 64K methods / references.

Android application files contain bytecode executable files in Dalvik Executable (or simply DEX ) files format.

Specifying the DEX format limits the total number of methods that can be referenced in a single file DEX to 65,536 - this includes your project and its dependencies.

In the context of computer science, the term Kilo, K, denotes 1024 (or 2 ^ 10). Since 65,536 is equivalent to 64 X 1,024, this limit is called the "64K limit of references."

Solution

To fix you need to follow two steps:

1. Add the dependency multidex

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

2. Enable multidex in your configuration:

defaultConfig {
    applicationId "MY_PACKAGE"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 8
    versionName "5.2"
    multiDexEnabled true
}

dexOptions {
    javaMaxHeapSize "4g"
}

3. You can also modify your class Application , just extend the MultiDexApplication class.

If you do not have a Application class, just add the code below on the <application> node, on your manifest.xml

<application
        android:name="android.support.multidex.MultiDexApplication" >

If you already have the class Application , simply extend it. Ex:

public class CustomApplication extends MultiDexApplication {
    /* Código aqui */
}
    
02.02.2018 / 14:36