android - Android Admob:缺少 google_app_id
问题描述
我正在尝试使用谷歌开发指南here和here实施奖励广告,在模拟器上使用测试广告单元时,广告会显示并正常调用回调ca-app-pub-3940256099942544/5224354917
,然后我用我的测试广告单元替换了测试广告单元,在物理设备,广告不会加载并调用函数onRewardedVideoAdFailedToLoad
。
在我发现的日志中
GoogleService 初始化失败,状态:10,名称为 google_app_id 的字符串资源中缺少 google 应用程序 ID 值。
我继续创建了一个 firebase 帐户,只是为了下载google-services.json
并获取mobilesdk_app_id
.然后我将它添加到字符串资源中。现在,当它启动时,广告无法再次加载,我在日志中发现了这一点
禁用数据收集。在 strings.xml 中找到了 google_app_id,但缺少 Google Analytics for Firebase。删除此值或添加 Google Analytics for Firebase 以恢复数据收集。
我正在使用com.google.gms:google-services:4.3.0
我在指南中找不到任何帮助
解决方案
你加了加吗
apply plugin: 'com.google.gms.google-services'
到你的模块 build.gradle 的底部?
您的 app_id 也需要转到您的 AndroidManifest.xml
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
见这里:https ://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml
推荐阅读
- identityserver4 - 实现一个通用授权服务,当我在多个应用程序/API 中将 Authorize 属性放在它上面时应该调用它
- windows - 当 EnableSslCertificateVerification 设置为 true (Confluent Kafka) - 证书验证失败
- python - python中的倒计时计时器覆盖与按键Tkinter
- r - 比较R中两个数据框之间的列值
- python - 在 Selenium 上的 Javascript 上下文中运行函数
- python - 我应该如何使用共享资源将我的 python 脚本容器化?
- paypal - 贝宝沙箱 - 验证身份
- python-3.x - 根据用户输入动态过滤 Pandas DataFrame
- php - pcntl_fork 子进程内存
- scala - 如何将类型参数作为函数参数发送