如何添加admob依赖项?

时间:2017-09-19 20:04:17

标签: android dependencies

我想在我的Android应用程序中添加一个admob横幅,但我无法添加此依赖项。你能帮帮我吗

compile 'com.google.android.gms:play-services-ads:11.2.0'

这是代码

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.google.android.gms:play-services-ads:11.2.0'
}

我收到了这个错误

Error:(26, 13) Failed to resolve: com.google.android.gms:play-services-ads:11.2.0
<a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile:D:/WorldOfKids/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

1 个答案:

答案 0 :(得分:0)

查看您的项目级build.gradle文件。它应该有maven指令

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