Anudeep Revuri
Anudeep Revuri

Reputation: 1

Error while building APK Android Studio 2.2.3

I am trying to generate a signed APK to test my app on a physical device. The app was working functionally before I tried to add the Google AdMob banner ad to my app. I keep getting 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/zzkf;

Here is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.coolappsforall.fartboard"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 2
        versionName "1.0.1"
        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'])
    compile 'com.google.android.gms:play-services-ads:11.6.0'
    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.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}

Not exactly sure what is causing the problem, if anyone knows, or if you need anything else, please let me know.

Thank you very much for your time and assistance in this matter.

Upvotes: 0

Views: 123

Answers (3)

Gurupreet
Gurupreet

Reputation: 39

// add line  multiDexEnabled true in defaultConfig

     defaultConfig {
            applicationId "com.coolappsforall.fartboard"
            minSdkVersion 14
            targetSdkVersion 25
            versionCode 2
            versionName "1.0.1"
    multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

//add below lines after closed bracts 

dexOptions {
        javaMaxHeapSize "4g"
    }

// change compilesdk version
compileSdkVersion 23
and

compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-appindexing:9.6.1'

Upvotes: 0

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29783

This is because you have mix different version of Google Play Service dependencies. Hence you need to make them the same:

dependencies {
    ...
    compile 'com.google.android.gms:play-services-ads:11.6.0'
    compile 'com.google.android.gms:play-services-appindexing:11.6.0'
}

Upvotes: 0

android_Muncher
android_Muncher

Reputation: 1057

This error happens when you have some classes that are overlapping from different libraries. Try to add this:

compile 'com.android.support:multidex:1.0.1'

Upvotes: 1

Related Questions