简体   繁体   English

为什么“在Android中添加Admob广告时出错”?

[英]Why “Error While Adding Admob Ads In Android”?

Trying to add google ads in my app. 尝试在我的应用中添加Google广告。

Here is the app-level build.gradle file: 这是应用程序级别的build.gradle文件:

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). 所有gms / firebase库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。 Found version 17.1.1,16.0.4,16.0.3,16.0.1,16.0.0. 找到版本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 示例包括com.google.android.gms:play-services-ads:17.1.1和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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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