0

I created an app with google services and now I want to generate a signed apk. But when I try to create this apk I get this error

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.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzqv;

This is my Gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
    applicationId "com.xxx.xxx.xxx"
    minSdkVersion 18
    targetSdkVersion 25
    versionCode 5
    versionName "2.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

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

 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile project(':BaseGameUtils')
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-games:10.2.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
testCompile 'junit:junit:4.12'
}

I've tried some Solutions from Stackoverflow but my Error still appears.

I hope you guys can help me to solve my problem

user5985727
  • 91
  • 1
  • 6

1 Answers1

0

try enabling multidex in build.gradle:

defaultConfig {
    ...
    multiDexEnabled true
}

Also add the dependencies:

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

Now in your Application class: Attach the multidex

    public class MyApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

}

Make sure u define the application class in manifest

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
  • Thanks for the fast comment. I tried your suggestion and now I get the following error : 'Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqv.class' – user5985727 Feb 21 '17 at 17:38
  • clean build the project..if the problem still appears try this solution: u r having duplicate entry http://stackoverflow.com/questions/26966843/java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult – rafsanahmad007 Feb 21 '17 at 18:03