AdMob - InterstitialAd not showing on real device - android

My banner adview showing correctly on real device and emulator. But interstilialad now showing real device although it showing correctly on emulator.
Every thing is okey for me. But i didn't understand why not showing.
EzFullScreenAds.class
public class EzFullScreenAds {
InterstitialAd mInterstitialAd;
Context context;
public EzFullScreenAds(Context context) { //constructor
this.context = context;
mInterstitialAd = new InterstitialAd(context);
mInterstitialAd.setAdUnitId(context.getString(R.string.adv_fullscreen));
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
super.onAdLoaded();
if (mInterstitialAd.isLoaded()) mInterstitialAd.show();
}
});
}
}
That is usage it.
new EzFullScreenAds(MainActivity.this);

May be because it cannot fill.
To show test ad on real device you must add real test device ID. AdRequest.DEVICE_ID_EMULATOR only work on emulator.
The Mobile Ads SDK uses the tag "Ads" when writing to logcat. You can
filter for that tag in Android Studio's logcat viewer, which makes it
easier to find your device's ID.
More information here:
https://firebase.google.com/docs/admob/android/targeting#adrequest

You did not add your device number as a test device.
The way you this is:
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("A1124HIDFBIUBQWASFDSAFD") // This is what is missing
.build();
The way how you can find your number is once you have the admob SDK installed(as you already have) You run the emulater and inside the log (that you can find in your working enviroment) press "ctrl + f" and search for "device".
Good Luck

Related

Having trouble getting Admob test banner to display on app

I'm trying to implement Google Admob into my app but the test banner isn't even displaying. I've managed to get rid of all debug error messages but still get nothing being display. Could it be hiding in the background? This code is implemented in my OnCreate method after OpenGL initialization. Have followed the guides on Google to the letter. I'm stumped.
MobileAds.initialize(this, new OnInitializationCompleteListener() {
#Override
public void onInitializationComplete(InitializationStatus initializationStatus){}
});
List<String> testDeviceIds = Arrays.asList("8X126XD7X13XD3X8CXE0X2BXA1X67XDX");
RequestConfiguration requestConfiguration
= new RequestConfiguration.Builder()
.setTestDeviceIds(testDeviceIds)
.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); // ANDROID TEST ID
AdRequest adrequest = new AdRequest.Builder().build();
adView.loadAd(adrequest);
I've run adrequest.isTestDevice(this) and it comes back as TRUE so my device seems to be working. I'm testing on a real device (Sony Xperia XZ). Any ideas??

NativeAdAdvanced - Incorrect native ad response. Click actions were not properly specified

I'm trying to implement NativeAd in my app.
Everything worked fine until yesterday, it's now printing these error logs.
I/Ads: WebView loading for native ads.
I/Ads: Javascript has loaded for native ads.
I/Ads: Received log message: <Google:HTML> Incorrect native ad response. Click actions were not properly specified
onAdFailedToLoad errorCode = 0
So I can't show native ads anymore.
Here's how I do the requests.
private AdRequest adRequest = new AdRequest.Builder()
.build();
private NativeAdOptions nativeAdOptions = new NativeAdOptions.Builder()
.setAdChoicesPlacement(ADCHOICES_TOP_RIGHT)
.setRequestMultipleImages(false)
.setReturnUrlsForImageAssets(true)
// Methods in the NativeAdOptions.Builder class can be
// used here to specify individual options settings.
.build();
AdLoader adLoader = new AdLoader.Builder(mContext, adUnitId)
.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
#Override
public void onAppInstallAdLoaded(NativeAppInstallAd appInstallAd) {
refreshAd(appInstallAd);
}
})
.forContentAd(new NativeContentAd.OnContentAdLoadedListener() {
#Override
public void onContentAdLoaded(NativeContentAd contentAd) {
refreshAd(contentAd);
}
})
.withAdListener(adListener)
.withNativeAdOptions(nativeAdOptions)
.build();
adLoader.loadAd(adRequest);
If I comment out forAppInstallAd then the ads can be downloaded again. But the fill rate is very low.
It looks like the SDK is rejecting the response sent down from the AdMob server, which is really weird. I don't think this is an issue that can be solved on StackOverflow, so I'd recommend creating a post in AdMob's SDK support forum, where the support team can try to dig into the issue.

Admob Ad's during Development

My doubt is not weather its ok to click on live ads during development.I did all the formalities to get my admob ad working . Then i saw that we should only use test add during development . so i used this code:
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4") // An example device ID
.build();
It worked fine. But then i change i back to the live ad code fearing that i would forget to do so later:
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
But now the ad wont appear during test run. Is that normal?
will the ad work when i finally launch the app?
I dont see anything wrong with your code, but something similar happened to me when implementing admob too.
I didnt have in count that the ad must be loaded before showing it, and that the loading may take some time. If you try to show an ad that its not loaded, a black activity might be shown.
You should implement some waiting time or a listener in order to be sure that the add is loaded before showing it.
public InterstitialAd interstitialAd;
[...]
public void setNewInterstitialRequest()
{
interstitialAd = new InterstitialAd(CurrActivity.this);
interstitialAd.setAdUnitId("ca-app-pub-***************************");
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice("ZY22247DJV")
.build();
// Begin loading your interstitial.
interstitialAd.loadAd(adRequest);
//add listener so you know is fully loaded
interstitialAd.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
[...] // <- code you want to execute as soon as the ad is loaded
}
});
}
public void displayAd() {
try {
//verify is loaded before showing a black screen
if (interstitialAd.isLoaded()) {
interstitialAd.show();
}
//else
// showToast("Not loaded");
}
catch (Exception ex){}
}
So taking this in mind, if you want for the ad to be shown inmediately when something happens, you should have it loaded before that event occurs.

How to remove the default interstitial ad from app

public void adShow() {
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-581420244534656/2222222");
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
requestNewInterstitial();
reseter();
}
mInterstitialAd.setAdListener(new AdListener() {
#Override
public void onAdClosed() {
requestNewInterstitial();
reseter();
}
});
}
private void requestNewInterstitial() {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("3D9834hiqewuiry48937498urequE")
.build();
mInterstitialAd.loadAd(adRequest);
}
}
I have tested the use of interstitial in my app using the default ad from google and it's working but now what must i do to make sure that the default orange ad is not displayed to users when I publish my app? I already have the AdUnitId.
So long as you have set a valid Ad unit id from the ad provider you're using, you should get real ads. The reason you most likely aren't seeing real ads is because of the line .addTestDevice("3D9834hiqewuiry48937498urequE") which basically says "Only show me the default orange ad on this device".
So, if you always test your app on the same device, this line is disabling real ads from appearing while you test (which is what you want). But this line will only disable real ads on a single device, the one you're using. On other devices, users will see real ads.

Admob interstitial ad gives an ERROR_CODE_INTERNAL_ERROR on AdListener

I try to ad Admob interstitial ad to my android app.
The google services are installed and work (I know it because banner ads do show).
The code runs this mehtod (on the UI thread):
private void cacheAds(List<String> types){
m_ad.setAdUnitId("ca-app-pub-7000418520362131/3312518208");
m_ad.setAdListener(new AdmobAdListener());
// Create ad request.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
.build();
// Begin loading your interstitial.
m_ad.loadAd(adRequest); // Has to be called on uiThread
}
Where AdmobAdListener is as follows:
private class AdmobAdListener extends AdListener{
public void onAdLoaded(){
System.out.println(); // HERE I HAVE A BREAKPOINT
}
public void onAdFailedToLoad(int errorCode){
System.out.println(); // HERE I HAVE A BREAKPOINT
}
}
For some reason, as soon as the code runs, It stops at the breakpoint on the onAdFailedToLoad() method, when the errorCode == ERROR_CODE_INTERNAL_ERROR.
Can someone think of why does it happen?
This happens when the network speed is too slow on the phone. If you are on gprs or gsm connection speed. If you are using an emulator then check your internet speed before testing.

Categories

Resources