android - Admob 错误代码 2 - 广告加载失败:2
问题描述
我正在尝试在 android 中显示智能尺寸横幅,但广告没有显示,当我看到日志时它显示:I/Ads: Ad failed to load : 2
. 我在互联网上搜索,发现问题是由于互联网连接造成的,但我的手机上有活跃且可靠的网络连接。下面是我的app
毕业典礼:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha3'
implementation 'com.android.support:support-v4:28.0.0'
testCompile 'junit:junit:4.12'
implementation 'com.airbnb.android:lottie:2.1.0'
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
}
以下是我的活动课:
MobileAds.initialize(this, Utils.ADMOB_APP_ID);
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("B2DD8C77E01892E0FF2A672FC77E2FF9").build();
mAdView.loadAd(adRequest);
这是布局:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/app_admob_id">
</com.google.android.gms.ads.AdView>
这是与广告相关的一些错误日志:
W/Ads: Invoke Firebase method getInstance error.
The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date
W/Ads: Not retrying to fetch app settings
I/Ads: Ad failed to load : 2
解决方案
此问题最常发生在没有 Internet 连接时。
推荐阅读
- html - 如何检测 YouTube 何时无法加载?
- python - Python 成本检查(已关闭)
- python - QGIS 3损坏/禁用的python
- kubernetes - EKS 工作节点可以设置在不同的区域吗
- c# - 如何以编程方式将 UWP 应用程序从后台(最小化模式)带到前台?
- amazon-web-services - 使用 AWS Cognito 向自动确认的用户发送邀请电子邮件
- laravel-livewire - 将数据传递给 livewire 中的组件
- hybris - 目录同步太慢,虽然同步已完成
- excel - 打开有或没有配额的excel文件路径之间的差异
- c++ - 拆分循环依赖的 CRTP 类标头时与函数调用不匹配