Согласно данным Google , попробуйте использовать ниже учетные данные для тестирования объявлений. В этом случае вам не нужно будет добавлять идентификатор устройства .
<!--Ad test credentials-->
<string name="admob_app_id">ca-app-pub-3940256099942544~3347511713</string>
<string name="banner_home_footer">ca-app-pub-3940256099942544/6300978111</string>
<string name="interstitial_full_screen">ca-app-pub-3940256099942544/1033173712</string>
<string name="rewarded_video">ca-app-pub-3940256099942544/5224354917</string>
<!--Ad live credentials-->
<string name="admob_app_id">add here your live app id</string>
<string name="banner_home_footer">add here your live footer id</string>
<string name="interstitial_full_screen">add here your live interstitial id</string>
<string name="rewarded_video">add here your live rewarded id</string>
Сейчас используйте функцию ниже для показа рекламы.
//Banner Ads
private void loadBannerAds(AdView mAdView) {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
}
//Interstitial Ads
private void loadInterstitialAds(final InterstitialAd mInterstitialAd) {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
// Load ads into Interstitial Ads
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
public void onAdLoaded() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
});
}
//RewardedVideo Ads
private void loadRewardedVideoAd(RewardedVideoAd mRewardedVideoAd) {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mRewardedVideoAd.loadAd(context.getResources().getString(R.string.rewarded_video), adRequest);
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
@Override
public void onRewarded(RewardItem rewardItem) {
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdClosed() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
}
@Override
public void onRewardedVideoCompleted() {
}
@Override
public void onRewardedVideoAdLoaded() {
try {
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onRewardedVideoAdOpened() {
}
@Override
public void onRewardedVideoStarted() {
}
});
// showing the ad to user
// make sure the ad is loaded completely before showing it
if (mRewardedVideoAd.isLoaded()) {
mRewardedVideoAd.show();
}
}
Я надеюсь, что это может помочь вам!