Admob Reward Video Ads don't work with test devices - android

We want to integrate Reward Video Ads in our app (https://firebase.google.com/docs/admob/android/rewarded-video).
The ads work great if we don't provide the test device. However, if we do, we receive error code 0 aka ERROR_CODE_INTERNAL_ERROR, so the execution goes through onRewardedVideoAdFailedToLoad.
Is this something somebody else has encountered?
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_ad);
MobileAds.initialize(this, APP_ID);
mAd = MobileAds.getRewardedVideoAdInstance(this);
mAd.setRewardedVideoAdListener(this);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("C67A1A9F2F19699874B7718074819FF9") // Test devices don't work work with rewarded video ads.
.build();
mAd.loadAd(AD_UNIT_ID, adRequest);
}
#Override
public void onRewardedVideoAdFailedToLoad(int errorCode) {
Toast.makeText(this, "onRewardedVideoAdFailedToLoad", Toast.LENGTH_SHORT).show();
}

I revisited this in November 2017 and the test device flag DOES now work with rewarded video Ads.
You can't use test devices for rewarded video, from this forum post:
"For Reward Videos, the following are our test Ad Unit ID:
iOS - ca-app-pub-3940256099942544/1712485313
Android - ca-app-pub-3940256099942544/5224354917
Note that Reward Video Ad Unit IDs are platform specific"

Related

Can I request new ad from onAdFailedToLoad?

During testing of my application, I noticed that I very frequently get ERROR_CODE_NO_FILL for Interstitial Ad. I think that the same situation with real ads might be one of the causes of low income from the application, so I want to increase the rate of showed ads. As the solution, I decided to make requests until I will get some app, so it might take from 5 to 50 requests until I will get out of onAdFailedToLoad. Is it a legitimate way to do this? Won't I get banned by AdMob with such way of getting more ads?
That's what I do in setAdListener in onCreate:
#Override
public void onAdFailedToLoad(int errorCode) {
requestNewInterstitial();
}
And requestNewInterstitial():
private void requestNewInterstitial() {
AdRequest adRequest = new AdRequest.Builder()
.build();
mInterstitialAd.loadAd(adRequest);
}
No, you won't get banned...
You can do this, but don't show the Ad as soon it is loaded, this will be a bombarding of Ads & user won't like that...

Admob live ads not showing in my application,while testing ads showing

Admob Live ads are not showing, while testing ads are showing. Live ads are not showing at all, I don't know what i am missing.
Here is code.
String.java XML
<!-- Insert Id admob -->
<string name="BannerAd_unit_id">cca-app-pub-1154915214031679/2100011458</string>
<string name="InterstitialAd_unit_id">ca-app-pub-1154915214031679/9049914448</string>
MainGame.Java Class
this.BANNER_AD_UNIT_ID = getResources().getString(R.string.BannerAd_unit_id);
showBanner();
screen java.class
public void showBanner() {
//banner ad
if (BANNER_AD_UNIT_ID.length() > 0) {
// Create an ad.
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(BANNER_AD_UNIT_ID);
//make ad visible on bottom of screen
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params1.addRule(RelativeLayout.CENTER_HORIZONTAL);
adView.setLayoutParams(params1);
layout.addView(adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//.addTestDevice("C01834A0B4A8FA4C03A0E09605F43819")//GalaxyS4*/
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
}
}
If I Remove comment ".addTestDevice" Then testing ads are showing, if I comment it then live ads not showing. I don't know what is going on, any help will be appreciated.
If you're not receiving real ads, but are receiving 'test ads' then the implementation should be ok.
If you just created the ad account, it takes a few hours until real ads will appear and sometimes there might be no adds available to show.
Set an adListener to your adView and see what you're getting back. It might be a ERROR_CODE_NO_FILL or it might give you other hints to solve the problem.
Make sure you have updated AdMob with your payment details (go to Payments Section for that).
Check your AdMob dashboard to see the status of your ads to check if they are active.
Verify you used the correct Ad Unit Id.
After you update your info, it may take up to 24 hours to verify your information. After verification, they will enable your ad serving. You will get an email notification saying your ads are now being served.
If the test ads are working fine then your implementation is correct, but there is an option of "Payment" in the admob account which you need to fill. After filling up that form you will receive an email regarding the confirmation of payment details and message indicating that whether your information was accepted by the admob team or not if yes then your live ads will be showing up. But keep in mind that for the first few time the ad won't show up. it takes time to appear after the approval as well.
Here is the code snippet for the error code to find what is going wrong
mAdView = (com.google.android.gms.ads.AdView) findViewById(R.id.adView);
mAdView.setAdListener(new com.google.android.gms.ads.AdListener() {
#Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Toast.makeText(HomeActivity.this, "onAdLoaded", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdFailedToLoad(int errorCode) {
if(errorCode==AdRequest.ERROR_CODE_INTERNAL_ERROR)
Toast.makeText(HomeActivity.this, "onAdFailedToLoad", Toast.LENGTH_SHORT).show();
// Code to be executed when an ad request fails.
}
#Override
public void onAdOpened() {
Toast.makeText(HomeActivity.this, "onAdOpened", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdLeftApplication() {
Toast.makeText(HomeActivity.this, "onAdLeftApplication", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdClosed() {
Toast.makeText(HomeActivity.this, "onAdClosed", Toast.LENGTH_SHORT).show();
}
})
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Get the error code:
ERROR_CODE_INTERNAL_ERROR - Something happened internally; for instance, an invalid response was received from the ad server.
ERROR_CODE_INVALID_REQUEST - The ad request was invalid; for instance, the ad unit ID was incorrect.
ERROR_CODE_NETWORK_ERROR - The ad request was unsuccessful due to network connectivity.
ERROR_CODE_NO_FILL - The ad request was successful, but no ad was returned due to lack of ad inventory.

Admob Not showing ads on real devices only showing on Test devices only

private void showInterstitialadd() {
mInterstitialAd = new InterstitialAd(MainActivity.this);
// set the ad unit ID
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
AdRequest adRequest = new AdRequest.Builder()
.build();
// Load ads into Interstitial Ads
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
public void onAdLoaded() {
showInterstitial();
}
});
}
private void showInterstitial() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
I am using the above function for showing Ads....and its working absolutely fine on my test device but when I remove that .addTestdevice().....and run on any other devices it does not shows up....
There may be no issue in your code but AdMob doesn't show ads on real device quickly. You have to wait for few days. Before that, you have to enter some details like address and payment account detail in your AdMob account.
Don't worry they guide via email.
After you enter details, wait for few days, you will be notified in AdMob account that ads are showing.
In my case, it takes 2 days and, only Banner and Interstitial ads were activated at that time and video ads still do not get loaded.
So if ads are showing on test device then it will also be showing in the real device. The only thing you have to do is complete AdMob account setup and wait.
Also, don't forget to remove .addTestdevice() code before checking on real device.

How google ads are shown on Android?

I did some testing with ads on my device and then pushed app to the play with with production unit ID. After a while when the version was available on play I deleted the debug build from my device and installed from playstore .
The code is same as what developer site suggests
mInterstitialAd = new InterstitialAd(callerActivity);
mInterstitialAd.setAdUnitId(callerActivity.getString(R.string.interstitial_ad_unit_id));
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
if (mInterstitialAd.isLoaded()) {
Log.i(TAG," Interstitial Add :Loaded");
mInterstitialAd.show();
}
else {
Log.i(TAG,"Could not load Interstitial Add");
}
But surprisingly I see following in logs
2:38.743 16617-16617/com.osfg.tictactoe I/Ads﹕ Starting ad request.
06-17 18:22:38.743 16617-16617/com.osfg.tictactoe I/Ads﹕ Use AdRequest.Builder.addTestDevice("235F7FAA8F49FF2CAA1DD2FAFE6B9E8A") to get test ads on this device.
06-17 18:22:40.529 16617-16617/com.osfg.tictactoe I/GamePlayOnClickListener﹕ Game Over. Some player won
06-17 18:22:43.551 16617-16617/com.osfg.tictactoe I/GamePlayOnClickListener﹕ Could not load Interstitial Add
06-17 18:22:43.551 16617-16617/com.osfg.tictactoe I/GamePlayOnClickListener﹕ Resetting game
It is still using my device as test device? Not sure what is happening here. Anyone has any prior experience on this? I know it calculates the hash but does it store it on admob server but again this is client call. How would it know? I am confused. Any suggestion is appreciated.
Most likely you're encountering this issue because mInterstitialAd.loadAd(adRequest); is calling a background thread to load a new ad, but you're checking to see if the ad has been loaded immediately. You don't give that background thread a chance to connect to the server, get the ad, etc.
To fix this, you need to place your code for when the ad has been loaded inside an AdListener, like so:
mInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
Log.i(TAG," Interstitial Add :Loaded");
}
#Override
public void onAdFailedToLoad(int error) {
Log.i(TAG,"Could not load Interstitial Add");
}
}
mInterstitialAd.loadAd(adRequest);
The if statement if (mInterstitialAd.isLoaded()) is for checking at a later time if the ad has been loaded, such as after the user does some action. Not when an activity begins or anything similar.

Admob interstitial with audio

I hope someone can give information about this.
I display interstitial ads with Admob. Some of them have music or sounds and my users get terrible annoyed because of this. So, does anyone know if there is a way to block ads with music or sound? Is there anyway to decline access to the loud speaker for the ads?
Thanks
I had the same issue. I was shocked to hear some audio in background too. This is what I did.
Mute the sound before showing the ad.
Unmute the sound onAdClosed() of AdListener. You can set the adListener on the interstitial ad while loading the ad.
private InterstitialAd interstitialAd;
private void showTheAd(){
_muteSound();
interstitialAd.show();
}
private void loadAd(){
interstitialAd = new InterstitialAd(context);
interstitialAd.setAdUnitId("ca-app-pub-XXXXXXx/XXXXXXXX");
AdRequest adRequest = new AdRequest.Builder().addTestDevice(
AdRequest.DEVICE_ID_EMULATOR).build();
interstitialAd.loadAd(adRequest);
interstitialAd.setAdListener(new AdListener() {
public void onAdClosed(){
_unmuteSound();
}
});
}
private void _unmuteSound(){
AudioManager aManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
aManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
}
private void _muteSound(){
AudioManager aManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
aManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
}
to mute an ad, just call MobileAds.setAppmuted(true)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
// Set app volume to be half of current device volume.
MobileAds.setAppVolume(0.5f); // or setAppMuted(true); to mute
...
}
from their forum page: https://groups.google.com/forum/#!topic/google-admob-ads-sdk/X7hQeehlJBI
The Google Mobile Ads SDK for Android has methods to set the current volume for incoming ads, based on the device's current volume level.
setAppVolume(float) - available in the Android AdMob SDK version 8.4
and up. setAppMuted(boolean) - available in the Android AdMob SDK version 9.0 and up.
for further readings, refer to https://developers.google.com/admob/android/global-settings and https://developers.google.com/android/reference/com/google/android/gms/ads/MobileAds
Well you can log-on to your AdMob account and go to your app and then choose to edit your interstitial ad-unit link in the table that displays the ad-units for this app.
In there, you'll see 3 Ad types as check-box options - Text, Image and Video. Uncheck the Video option and save your settings.
You've now solved successfully the problem of showing loud audio/video ads that nag your users. Cheers!

Categories

Resources