Reputation: 157
My Ads donot show.
I am developing an app that requires Ads. Currently for testing, I have the app in the Internal Test Track of Google Play console for closed Testing. So, I cannot link it to an app in Play store in Admob.
So, to test them, all the while I have been Sample Test Ad Units, specifically Interstitial and Rewarded Video Ads. They load fine.
Today, I decided to switch to production Ads, as I wanted to release the App. So , I have created new Ad Units for both Rewarded and intersitial. Replaced the test Ad ID units with production Ad Unit IDs. I see "Ad failed to load : 0" .
Instead of using sample Ad Units, I tried making my device set Test Device. I see the follwing log
I/Ads: This request is sent from a test device. I/Ads: Ad failed to load : 0
I am not sure what the issue is. I am still in the internal Test Track. Is the an issue? Do the production Ads work only when linked to an app in Google Play?
Please let me know where I am going wrong. Please see the attached image for Admob Ad units
The code is as show below:
Manifest.xml:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx" />
build.gradle:
implementation 'com.google.android.gms:play-services-ads:19.2.0'
Implementing AdMob :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Rest of the code
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
Log.w(TAG, " initialized mobile ad");
}
});
List<String> testDeviceIds = Arrays.asList("xxxxxxxxxxxxxxxxxxxxxxxxx");
RequestConfiguration configuration =
new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
MobileAds.setRequestConfiguration(configuration);
}
public void loadInterstitialAd(){
mInterstitialAd = new InterstitialAd(this);
this.rewardedAd = new RewardedAd(this, "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
//mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
}
@Override
public void onAdClosed() {
Log.w(TAG, "Interstitial ad cloed ");
onInterstitialshowed();
}
});
}
public void loadRewardedAd(){
this.rewardedAd = new RewardedAd(this, "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
//this.rewardedAd = new RewardedAd(this, "ca-app-pub-3940256099942544/5224354917");
RewardedAdLoadCallback callback = new RewardedAdLoadCallback(){
@Override
public void onRewardedAdFailedToLoad(int i) {
super.onRewardedAdFailedToLoad(i);
}
@Override
public void onRewardedAdLoaded() {
super.onRewardedAdLoaded();
showRewardedAd();
}
};
this.rewardedAd.loadAd(new AdRequest.Builder().build(), callback);
}
public void showRewardedAd(){
if(rewardedAd.isLoaded()){
RewardedAdCallback callback = new RewardedAdCallback() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
Log.w(TAG, "onUserEarnedReward");
}
@Override
public void onRewardedAdOpened() {
super.onRewardedAdOpened();
Log.w(TAG, "OnRewardAdOpened");
}
@Override
public void onRewardedAdClosed() {
super.onRewardedAdClosed();
onRewardedAdLoadedOnClick();
}
@Override
public void onRewardedAdFailedToShow(int i) {
super.onRewardedAdFailedToShow(i);
Log.w(TAG, "onRewardedAdFailedToShow");
}
};
this.rewardedAd.show(this, callback);
}else{
Log.i(TAG, "Ad not loaded");
}
}
Upvotes: 0
Views: 610
Reputation: 73
I had the same problem with SDK ANDROID LEVEL 30. When I changed it to SDK ANDROID LEVEL 29 the ADS showed.
Upvotes: 1