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

Asked

Viewed 1,243 times

0

I’m getting this mistake every time I try to give one 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 Intermediates Transforms Dex release folders 1000 1f main C: Users M Documents MY_APP_NAME app build Intermediates Transforms proguard release jars 3 1f main.jar}

Who knows what I need to do PLEASE help me, because I can not update my app >:[, it even compiles, but the devices do not let install...

My build.Radle 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 debug version tb. I’m already freaking out!!! Someone knows what to do...

Thank you.

EDITED

Now it appears that qd arrives at this task:

:app:transformClassesWithDexBuilderForDebug

(last task q appears in Gradle Console)

and in Messages appears:

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

Cause: Forced cancellation of an existing connection by the host remote

I tried to update 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 on 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 (trying to update only), it just started happening 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 error appears tb.

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

1 answer

0

About the error

Probably your app has more than 64K methods/references.

Android app files contain files from bytecode executable in file format Dalvik Executable (or simply DEX).

The specification of the format DEX limits the total 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 1,024 (or 2 10). Since 65,536 is equivalent to 64 X 1,024, this limit is called the "64 K reference limit".

Solution

To fix you need to follow two steps:

1. Add dependency multidex

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

2. Activate the multidex in its 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 class MultiDexApplication.

If you don’t have a class Application, just add the code below the node <application>, in his manifest.xml

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

If you already own the class Application, just extend. Ex:

public class CustomApplication extends MultiDexApplication {
    /* Código aqui */
}
  • Hi, thanks for your help! Just so I understand correctly, this Dex refers to the final size of the app, or the Qtd of methods of a specific Arq, because my app is 70M in size, has already been published, and sp compiled normally with the previous versions the AS, in this new version 3.0.1 q appeared this groundhog!!! I edited my question, if you can take a look, I appreciate it mto.

  • @Emilyr This is not due to the size of the app, but rather the amount of class/reference methods the project uses. I edited item 2 of my reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.