0

Trying to add google ads in my app.

Here is the app-level build.gradle file:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.student.shopifysalespediasample"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services-ads:17.1.1'
}

And I'm getting an error in this line :

 implementation 'com.google.android.gms:play-services-ads:17.1.1'

The Error Reads:

All gms/firebase libraries must use the exact same version specification(mixing versions can lead to runtime crashes). Found version 17.1.1,16.0.4,16.0.3,16.0.1,16.0.0. Examples include com.google.android.gms:play-services-ads:17.1.1 and com.google.android.gms:play-services-measurement-base:16.0.4

Please help, I have almost completed my app. The final step of adding ads is remaining. Your help is highly appreciated. Thanks!

ADM
  • 20,406
  • 11
  • 52
  • 83
  • https://mvnrepository.com/artifact/com.google.android.gms/play-services-ads/17.1.1 play service ads have different version of dependency. You need to exclude the transitive dependencies – Shubham AgaRwal Feb 23 '19 at 05:24
  • Possible duplicate of [All com.android.support libraries must use the exact same version specification](https://stackoverflow.com/questions/42374151/all-com-android-support-libraries-must-use-the-exact-same-version-specification) – Shubham AgaRwal Feb 23 '19 at 05:24
  • Thanks for your time. I've resolved this error by adding 15.0.0 instead of 17.1.1 – Akshat Chaturvedi Feb 23 '19 at 19:17

1 Answers1

0

your dependency version not same, use this dependency

implementation 'com.google.android.gms:play-services-ads:16.0.0'
Mayur Dabhi
  • 3,607
  • 2
  • 14
  • 25