AdMob with SDK box not showing ads. Ad isAvailable always false

I’ve installed Admob via SDKBox into my coco2dx v3.10 project.

in the AppDelegate::applicationDidFinishLaunching(), i call:

sdkbox::PluginAdMob::init();
sdkbox::PluginAdMob::show("home");

and nothing happens.

Checking isAvailable returns false all the time.

sdkbox::PluginAdMob::isAvailable("home")

I’ve replace the id for the ‘id’ of my own ad in the ‘sdkbox_config.json’

Does my application need to be published for the ad’s to show up? I’d like to test the ads before publishing. Is there a way to do this?

I’ve tried adding:

sdkbox::PluginAdMob::setTestDevices(MY_HASHED_DEVICE_ID);

but still no luck.

So for admob, you always have to cache the ad before show it for each ad…

1 Like

Hi, nite.

Thanks for the reply.

I’ve tried what you mentioned, I now call:

sdkbox::PluginAdMob::init();

then

sdkbox::PluginAdMob::cache("home");

then

sdkbox::PluginAdMob::show("home");

And still nothing. And isAvailable still returns false.

Any other ideas?

Hi. You probably can’t show ads because you try to show them before it’s actually cached(ad received). Could you try to implement sdkbox admob listeners, and when the ad received, show it:

class IMListener : public sdkbox::AdMobListener {
public:
    virtual void adViewDidReceiveAd(const std::string &name) {
        log("admob adViewDidReceiveAd %s: ", name.c_str());
        PluginAdMob::show(kHomeBanner);
        //if (showText) showText(StringUtils::format("%s name=%s", __FUNCTION__, name.c_str()));
    }
    virtual void adViewDidFailToReceiveAdWithError(const std::string &name, const std::string &msg) {
        log("admob adViewDidFailToReceiveAdWithError %s: ", msg.c_str());
        //if (showText) showText(StringUtils::format("%s name=%s, msg=%s", __FUNCTION__, name.c_str(), msg.c_str()));
    }
    virtual void adViewWillPresentScreen(const std::string &name) {
        log("admob adViewWillPresentScreen %s: ", name.c_str());
        //if (showText) showText(StringUtils::format("%s name=%s", __FUNCTION__, name.c_str()));
    }
    virtual void adViewDidDismissScreen(const std::string &name) {
        log("admob adViewDidDismissScreen %s: ", name.c_str());
        //if (showText) showText(StringUtils::format("%s name=%s", __FUNCTION__, name.c_str()));
    }
    virtual void adViewWillDismissScreen(const std::string &name) {
        //if (showText) showText(StringUtils::format("%s name=%s", __FUNCTION__, name.c_str()));

        //if (name == "gameover") {
            //sdkbox::PluginAdMob::cache(kHomeBanner);
            //sdkbox::PluginAdMob::cache(kGameOverAd);
        //}
        log("admob adViewWillDismissScreen %s: ", name.c_str());
    }
    virtual void adViewWillLeaveApplication(const std::string &name) {
        //if (showText) showText(StringUtils::format("%s name=%s", __FUNCTION__, name.c_str()));
        log("admob adViewWillLeaveApplication %s: ", name.c_str());
    }
};

Check out the adViewDidReceiveAd

1 Like

Thanks, hgokturk.

That’s exactly what was happening. The banner must not have been cached yet. I added the show into the delegate method and now it’s showing up.

Thanks nite, for letting me know that the ad needed to be cached first. That doesn’t seem it be in the documentation anywhere and I was effectively omitting to do so.

Thanks @Marquisd for pointing out.
I will update the documentation.

You are very welcome.

Hello @hgokturk

We have added the cache information for admob into our documentation.
However we are coming up with auto-caching in coming releases. :smile:

Best,
Pabitra

1 Like

That’s how you cocos2d-x guys do it! :smiley: Thanks.

@hgokturk Thanks! It does help me a lot!

@pabitrapadhy Thanks too!!

I’m having the same issue with sdkbox and Im using Eclipse for the build. Are you using Android Studio?

Hey @damort

Could you please let us know, what version of SDKBOX you are using ?
If not on the latest version, please update using - sdkbox update

But, if you are already in the latest version, could you please post us what logs you are getting… !!

Best,
Pabitra

sdkbox update returns

C:\projects\cocos2dx\shipwreck>sdkbox update
_______ ______  _     _ ______   _____  _     _
|______ |     \ |____/  |_____] |     |  \___/
______| |_____/ |    \_ |_____] |_____| _/   \_
Copyright (c) 2015 SDKBOX Inc. v1.0.0.7
A newer version of SDKBOX is available, would you like to update v1.0.0.7 to v1.0.0.9?
Type [Y]es, [n]o or [q]uit
y
[###################################] 100%
 SHA1 of update does not match
Found  : df2321aa346efae7988f0bff9f2aa83f7367c8ee
Needed : 8f5fa467ace39e9cfb1b18db53a221bca7eadf87
 Installation failed :(

I am facing same issue on IOS.

What I am not sure is how long should I wait for ad to cache ?

Initially I tried to cache it right below init();

sdkbox::PluginAdMob::init();
sdkbox::PluginAdMob::cache("home");

Here I would get message saying that request was ignored probably because PluginAdMob was not fully initialized.

I then called the cache function later and tried. However it did not work either.

I also noticed this error thrown from the Firebase that I had previously integrated and same error is also displayed from the callback adViewDidFailToReceiveAdWithError.

errro:Request Error: No ad to show.

My config code is as follows.

"AdMob": {
            "test":true,
            "ads": {
    "extratime":{
                    "id":"some id here",
                    "type":"rewarded_video"
                },
    "freetokens":{
                    "id":"some id here",
                    "type":"rewarded_video"
                },
    "doubletokenreward":{
                    "id":"some id here",
                    "type":"rewarded_video"
                }
  
            }
        },

Apart from the above error, I do not see any other error related to ads.

I also tried to display test ads using test ad unit ids yet I get the same error.

What might be causing this ?

@nite @yinjimmy

Recently, I got some email from Google, said there are some guys used admob illegally, so Google stopped advertising.

Maybe you can change your bundle / package it, then test again.

I can get interstitial ad:

and rewarded video:

adViewDidReceiveAd name=rewarded
adViewWillPresentScreen name=rewarded

One more thing, app can not 100% get ad from AdMob, plz try several times.

I modified the code such that if ad is not available it will cache so that I can try to cache several times.

if(sdkbox::PluginAdMob::isAvailable("freetokens"))
{
   sdkbox::PluginAdMob::show("freetokens");
}
else
{
    sdkbox::PluginAdMob::cache("freetokens");
}

Now I get the error No ad returned from any ad server.

Are you sure that there is nothing from the implementation side that I should double check?

nothing from admob.

There was some issue in configuring Ad Mob and that was resolved yesterday. I was provided with new Ad Unit IDs but even with those IDs, I am not able to view any ad. How long should I wait after a new Ad Unit gets created in order to view ads using that Ad Unit ID ??