0

I just convert my project eclipse to the android studio, and now I want to add Google Interstitial Ads, but it gives an error like

Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompat; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatHoneycomb; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityCompatJB; Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActivityOptionsCompat;

My Project Gradle file is :

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        //classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {url 'https://maven.google.com'}
    }
}

and my app module gradle is :

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile project(':Rajawali')
    compile project(':aFileChooser')
    compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
    compile 'com.google.android.gms:play-services-ads:11.0.4'
    compile 'com.android.support:multidex:1.0.1'
}

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"

    dexOptions {
        preDexLibraries = false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

here is my all gradle file, now how can I add Google Interstitial Add in my App. I also try to add Google play service in my Project gradle file and add Google play service plugin in the module but not working.

Abhay Tomar
  • 175
  • 1
  • 9
Gaurav Mandlik
  • 525
  • 1
  • 9
  • 42

2 Answers2

0

Add this to your build.gradle file of your app module

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.google.android.gms:play-services-ads:11.8.0' // this line only
}

Reference

Abhay Tomar
  • 175
  • 1
  • 9
  • Error:Execution failed for task ':VideoLiveWallpaper:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/BackStackRecord$Op.class – Gaurav Mandlik Jan 10 '18 at 12:32
  • Update your google play services library to latest Version Reference: https://stackoverflow.com/questions/36763382/apptransformclasseswithjarmergingfordebug-failed – Abhay Tomar Jan 10 '18 at 12:37
  • i am using compile 'com.google.android.gms:play-services-ads:11.8.0' and also try compile 'com.google.android.gms:play-services-ads:11.0.4' but result is same. – Gaurav Mandlik Jan 10 '18 at 12:42
  • add this lib to your dependencies in app module : compile 'com.android.support:appcompat-v7:27.0.2' – Abhay Tomar Jan 10 '18 at 12:53
  • duplicate entry: android/support/v4/app/ActivityCompatHoneycomb.class – Gaurav Mandlik Jan 11 '18 at 11:31
  • def androidSupportVersion = '27.0.+' compile("com.android.support:appcompat-v7:${androidSupportVersion}") { force = true } def gmsVersion = '11.+' compile("com.google.android.gms:play-services-ads:${gmsVersion}") { force = true } – Gaurav Mandlik Jan 11 '18 at 11:31
0

Did you get a look at this ? https://developers.google.com/admob/android/quick-start

The error message you get seems to be about libraries that you added. Some classes seems to be added twice in your project so get a look at those lib to check what is in it. You might need to exclude modules in it ex : exclude module: 'support-v4'

adc
  • 76
  • 8