我正在尝试将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'
答案 0 :(得分:3)
我认为你忘了包含admob依赖:
compile 'com.google.firebase:firebase-ads:9.4.0'
核心包只是分析,如下所示: https://firebase.google.com/docs/android/setup#available_libraries