0

I'm trying to integrate Millennial Media SDK 6.4 in my Android app, but it shows an error message below when I run the app on my phone.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback$1.class

At first, I run the sample code with latest SDK downloaded directly from Millennial Media site, and it worked perfectly on my device. Then I migrated the inline ad code into my app following the official integration guide and there were no any problems when compiling or cleaning the project until I attempted running it in my phone. Please see my build.gradle file below.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId '<My Application ID>'
        minSdkVersion 16
        targetSdkVersion 25
        versionName '1.0'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        versionCode 5
        versionNameSuffix '5'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding.enabled = true;
    productFlavors {
    }
}

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:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:preference-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.firebase:firebase-jobdispatcher:0.6.0'
    compile 'com.android.support:support-v4:25.3.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile project(':android-ad-sdk')
    compile 'com.google.android.gms:play-services:10.2.4'
}

I have tried cleaning gradlew, updating the gradle version and restarting the project, but nothing works. I have also contacted Millennial Media support team a day ago, though no response has been heard yet.

Have anyone seen this problem or known how to fix. Please give me any advices that I will appreciate. Or do you use other ad network providers that could be better than Millennial Media?

Cheers.

Update 1:

I've tried commenting compile "com.google.android.gms:play-services:10.2.4". Although it built the app, it showed a fatal exception below when I started the activity with the ad.

E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1  
java.lang.NoClassDefFoundError: com.google.android.gms.common.GoogleApiAvailability
at com.millennialmedia.internal.utils.EnvironmentUtils.getAdInfo(EnvironmentUtils.java:356)
at com.millennialmedia.internal.utils.EnvironmentUtils$1.run(EnvironmentUtils.java:132)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
  • try commenting this `compile 'com.google.android.gms:play-services:10.2.4'` and then build to see if the error still persists? – Muhammad Babar May 05 '17 at 05:49
  • Thanks for your advice, and I've tried it already. It did build the app, but when I loaded the activity with the ad, it show another error. – Jinbin Liang May 05 '17 at 07:22
  • It show a fatal exception like this, `E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1 java.lang.NoClassDefFoundError: com.google.android.gms.common.GoogleApiAvailability`. – Jinbin Liang May 05 '17 at 07:33
  • `at com.millennialmedia.internal.utils.EnvironmentUtils.getAdInfo(EnvironmentUtils.java:356) at com.millennialmedia.internal.utils.EnvironmentUtils$1.run(EnvironmentUtils.java:132) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856)` – Jinbin Liang May 05 '17 at 07:35
  • Sorry a bit late here. You could try using `./gradlew app:dependencies` to see where the conflict is present. Once you find where the conflict is you can add an exclude to that library `compile ('some.lib.group:module:X.X.X') {exclude (group: 'some.name', module: 'some.module)}` Hope this helps somebody out there. – Vince Jun 08 '18 at 23:25

0 Answers0