导入谷歌播放服务到Android项目失败

时间:2016-08-23 20:40:52

标签: android firebase admob google-play-services

我正在尝试将AdMob添加到我的应用程序中。我按照here列出的说明进行操作,但会导致错误导致导入失败并且com.google.android.gms.ads无法解决:

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

这是我的根gradle文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        // ...
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

这是我的app .gradle文件:

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'

}
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:3)

我认为你忘了包含admob依赖:

compile 'com.google.firebase:firebase-ads:9.4.0'

核心包只是分析,如下所示: https://firebase.google.com/docs/android/setup#available_libraries