Admob 横幅广告未显示
Admob Banner ad is not displaying
没有展示广告。我已将我的设备配置为测试单元。
MobileAds.initialize(getActivity(), new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
//setup test device
MobileAds.setRequestConfiguration(
new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("A222ECB948AFB6D392596135E7D33D35"))
.build());
mAdView = root.findViewById(R.id.adView);
final AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setAdListener( new AdListener(){
@Override
public void onAdLoaded() {
Log.i("nonsinglefragment","ad loaded");
super.onAdLoaded();
}
@Override
public void onAdFailedToLoad(int i) {
Log.i("nonsinglefragment","ad load failed "+i);
super.onAdFailedToLoad(i);
}
});
Xml代码
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="@string/ad_id1"/>
这是logcat
I/Ads: Updating ad debug logging enablement.
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
W/Ads: Update ad debug logging enablement as false
I/Ads: Ad failed to load : 0
I/Ads: Ad failed to load : 0
google 的示例测试 ID 一切正常。当我实现我的单元 ID 时问题开始了。
请确保您的 Admob 帐户处于活动状态。如果它处于活动状态,那么您可以等待几个小时,有时广告需要一些时间才能出现。
google 文档是这样说的:
"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."
没有展示广告。我已将我的设备配置为测试单元。
MobileAds.initialize(getActivity(), new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
//setup test device
MobileAds.setRequestConfiguration(
new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("A222ECB948AFB6D392596135E7D33D35"))
.build());
mAdView = root.findViewById(R.id.adView);
final AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setAdListener( new AdListener(){
@Override
public void onAdLoaded() {
Log.i("nonsinglefragment","ad loaded");
super.onAdLoaded();
}
@Override
public void onAdFailedToLoad(int i) {
Log.i("nonsinglefragment","ad load failed "+i);
super.onAdFailedToLoad(i);
}
});
Xml代码
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="@string/ad_id1"/>
这是logcat
I/Ads: Updating ad debug logging enablement.
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
W/Ads: Update ad debug logging enablement as false
I/Ads: Ad failed to load : 0
I/Ads: Ad failed to load : 0
google 的示例测试 ID 一切正常。当我实现我的单元 ID 时问题开始了。
请确保您的 Admob 帐户处于活动状态。如果它处于活动状态,那么您可以等待几个小时,有时广告需要一些时间才能出现。
google 文档是这样说的:
"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."