当我使用firebase中可用的admob选项时,它要求我添加以下依赖项'com.google.firebase:firebase-ads:15.0.1:15.0.0'
但是在构建gradle之后,它给了我Failed to resolve: firebase-ads-15.0.0
这个错误,所以我使用了'com.google.firebase:firebase-ads:12.0.1'
,效果很好,但与此同时我看不到广告。这些是我的依赖项:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:26.1.0'
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.daimajia.easing:library:2.0@aar'
implementation 'com.daimajia.androidanimations:library:2.3@aar'
implementation 'com.google.android.gms:play-services:12.0.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:12.0.1'
//implementation 'com.google.firebase:firebase-ads:12.0.1'
//implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-ads:15.0.1:15.0.0'
}
这是我的项目级别gradle文件
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
//classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.0'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:1)
Firebase 核心和广告的编译版本应相同 试试这个版本 16.0.4
它看起来像这样:
implementation com.google.firebase:firebase-core:16.0.4
implementation 'com.google.firebase:firebase-ads:16.0.4'
答案 1 :(得分:0)
更改行:
implementation 'com.google.firebase:firebase-ads:15.0.1:15.0.0'
到
implementation 'com.google.firebase:firebase-ads:15.0.1'