Error:Execution failed for task ':app:transformClassesWithDexForRelease' de Lcom/google/android/gms/Internal/zzbw; Would anyone know this error?

Asked

Viewed 698 times

1

In my Android Studio is giving the following error when trying to make a store apk:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.Transform.Transformexception: com.android.ide.common.process.Processexception: java.util.Concurrent.Executionexception: com.android.Dex.Dexexception: Multiple Dex files define Lcom/google/android/gms/Internal/zzbw;

Could someone help me with this mistake.

Here are the dependencies of my build.Radle project

dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 

        {
                exclude group: 'com.android.support', module: 'support-annotations'
            })

            compile 'com.android.support:support-v4:24.2.1'
            compile 'com.android.support:appcompat-v7:24.2.1'
            compile 'com.android.support:recyclerview-v7:24.2.1'

            compile 'com.nispok:snackbar:2.10.10'
            compile 'com.android.support:design:24.2.1'
            compile 'com.android.support:support-vector-drawable:24.2.1'

            compile 'com.google.android.gms:play-services-appindexing:9.6.1'
            compile 'com.google.android.gms:play-services-auth:9.6.1' 
            compile 'com.google.android.gms:play-services-fitness:9.6.1'
            compile 'com.google.android.gms:play-services-wearable:9.6.1' 

            compile 'com.google.firebase:firebase-core:9.6.1' 
            compile 'com.google.firebase:firebase-messaging:9.6.1' 
            compile 'com.google.firebase:firebase-auth:9.6.1'  
            compile 'com.google.firebase:firebase-database:9.6.1' 

            testCompile 'junit:junit:4.12'


        }
  • Are you using Multidex? https://developer.android.com/studio/build/multidex.html

  • I do not use multidex, in this case it is necessary?

  • Maybe it’s because you use bilbiotecas of support, play-services and firebase that have many calls to methods. When the application has more than 64k calls to methods then you need multidex. It is simple to enable, in the official documentation above explains well

1 answer

8


As far as we can tell, you’re using a lot of external libraries. Considering this, we have to perhaps, I say perhaps, exceed the total limit of methods to be referenced in your project.

Explanation: Building Apps with Over 65K Methods

Android Application Files (APK) contain bytecode files executable in Dalvik Executable (DEX) format, which contain code compiled, used to run your application. The Dalvik specification Executables limit the total number of methods that can be referenced within a single DEX file at 65,536, including Android framework methods, library methods, and methods in your own code. To exceed this limit you will have to configure the build process of your application to generate more of a DEX file, configuration known as multidex.

Solution:

  1. You should try to format the dependencies (libraries), wipe as much of your code as possible, to remove the excess classes to try not to exceed the limit. Then Gradle in Android Studio and check if the error will occur again. If it does not resolve, go to the second option.

  2. Add to build.gradle (app module).

android {
   ...
   defaultConfig {
      ...
      multiDexEnabled true
   }
}

Several great developers have written about this topic, and some examples are here:

Browser other questions tagged

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