简体   繁体   中英

Why “Error While Adding Admob Ads In Android”?

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!

您的依赖版本不相同,请使用此依赖

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM