繁体   English   中英

实施'com.google.android.gms:play-services-ads:18.1.0'

[英]Implementation 'com.google.android.gms:play-services-ads:18.1.0'

我想向我的项目中添加广告,但是当我添加以下行时,它不起作用:

implementation 'com.google.android.gms:play-services-ads:18.1.0'

这些是来自build.gradle的依赖build.gradle

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    implementation 'com.google.android.gms:play-services-ads:18.1.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

您是否在内部对google()库或maven { url "https://maven.google.com" }顶级build.gradle文件引用? 日志中是否存在某些特定错误?

尝试创建一个新项目并复制旧项目文件并粘贴到一个新项目中。 如果有帮助!

您可能没有将Google Services Gradle插件以及google-services.json文件(可以从Firebase控制台下载)添加到项目中-因此您的应用程序无法通过身份验证。

com.google.android.gms.ads.APPLICATION_ID添加到AndroidManifest.xml具有相同的效果,因为Play Services插件会在构建时从google-services.json添加值。

...如果仅使用AdMob,则应首选第二个选项。

暂无
暂无

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

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