Problems with AdMob Ads

Hey guys, 

i want to have ads in my game and for this i’m using AdMobs but i always have problems with it.

I’m using this code here:

appID = "ca-app-pub-xxxxxxxxxxx/xxxxxxxxx" local adProvider = "admob" local function adListener( event ) -- The 'event' table includes: -- event.name: string value of "adsRequest" -- event.response: message from the ad provider about the status of this request -- event.phase: string value of "loaded", "shown", or "refresh" -- event.type: string value of "banner" or "interstitial" -- event.isError: boolean true or false local msg = event.response -- Quick debug message regarding the response from the library print( "Message from the ads library: ", msg ) if ( event.isError ) then print( "Error, no ad received", msg ) elseif ( event.phase == "loaded" ) then print( "loaded" ) elseif ( event.phase == "shown" ) then print( "shwon" ) else print( "Ah ha! Got one!" ) end end ads.init( adProvider, appID, adListener ) ads.show( "banner", { x=display.contentWidth, y=1000, appId="ca-app-pub-xxxxxxxxxxx/xxxxxxxx", testMode = true})

I had the testMode in false 1 or 2 days ago and after a lot of hours i’ve got ads in my app, but everytime i change my code, the ad will not be shown for a lot of hours. Is that normal?

Also, is it right that on every change in my code, the ad will first disappear?

My last change was about 24 hours ago and till now no ads are shown and i get a different message: “the ad request was successful but no ad was returned due to lack of ad inventory”.

And even when i’m now testing with testMode = true, i dont get any ads shown, i always get the same message.

Is this all normal or am i doing something wrong? Its really hard to test if you have to wait so many hours every time you change something in the code, this cant be normal. And now it seems that i wont get any ads…

Thank you.

Br,

ajaks

I haven’t ran the code, but in your show call you set “x” to the width of the display, which will surely put the ad ( as that’s the left position of the ad ) off screen?

Try setting that to 0. Also make sure the “y” value is correct, as a test set that to 0 as well.

@ajaks,

Can you post your build.settings file, please?

When you use the word ‘_ code _’:
 

 but everytime i change my [u][b]code[/b][/u], the ad will not be shown for a lot of hours. Is that normal?

  
Do you mean the Lua code.  Or do you mean the mean the ad campaign apID?

Also, if that’s your actual code, you’re calling .show() immediately after .init() which for many of our plugins is an asynchronous operation meaning it starts the init process in the background because it can take some time and you don’t want to block the app. I’m unsure about the AdMob plugin, but there is a good chance you’re calling .show() before .init() finishes.

Now if you’re .show() is reasonably delayed and you just pasted the code in to show us, then that’s probably not the answer.

Rob

In AdMobs its not possible to put Ads off the screen, thats why the y is that big, it puts the Ad to the bottom of the app.

Sure, here it is:

settings = { orientation = { default = "landscapeLeft", supported = { "landscapeRight", "landscapeLeft" } }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, googlePlayGamesAppId = "(here is a app id)", --largeHeap = true }, plugins = { -- key is the name passed to Lua's 'require()' ["plugin.google.iap.v3"] = { -- required publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, -- Google play game services ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, ["CoronaProvider.gameNetwork.apple"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, ["iphone-sim"]=true }, }, }, iphone = { plist = { CFBundleIconFiles = { "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-40@3x.png", }, UILaunchImages = { { --iPhone 4 Portait ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{320, 480}" }, { --iPhone 4 LandscapeLeft ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{320, 480}" }, { --iPhone 4 LandscapeRight ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{320, 480}" }, { --iPhone 5 Portait ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{320, 568}" }, { --iPhone 5 LandscapeLeft ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{320, 568}" }, { --iPhone 5 LandscapeRight ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{320, 568}" }, { -- iPad / iPad Retina ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-Portrait", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{768, 1024}" }, { -- iPad / iPad Retina ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-Landscape", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{768, 1024}" }, { -- iPad / iPad Retina ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-Landscape", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{768, 1024}" }, { --iPhone 6 Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{375, 667}" }, { --iPhone 6 LandscapeLeft ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{375, 667}" }, { --iPhone 6 LandscapeRight ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{375, 667}" }, { -- iPhone 6 Plus Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-736h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{414, 736}" }, { -- iPhone 6 Plus landscape left ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-Landscape-736h", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{414, 736}" }, { -- iPhone 6 Plus landscape right ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-Landscape-736h", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{414, 736}" } }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work --[[FacebookAppID = "XXXXXXXXXXXXXXXX", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXXXXXXX", -- replace XXXXXXXXX with your facebook appId } } }, --]] --[[UIAppFonts = { "immortal.ttf", "district.ttf", "carbontype.ttf", "Agency.ttf", "AgencyFB-Bold.ttf", }, --]] } }, excludeFiles = { iphone = { 'Icon-\*dpi.png', 'audio/\*.oog' }, android = { 'Icon.png', 'Icon-6\*.png', 'Icon-7\*.png', 'Icon-Small\*.png', 'Icon@2x.png', 'Default-568h@2x.png', 'audio/\*.m4a' } }, }

I mean my Lua code. Thats why this is so annoying…

The appID / bannerID is always the same.

Thats a good argument, i will try to call the show() later.

You’re trying to use the legacy AdMob plugin.
It was removed on March 1st 2017 as mentioned in this post from January:
https://coronalabs.com/blog/2017/01/26/legacy-admob-plugin-to-be-removed-march-1-2017/

If you want to continue to use AdMob you must buy the AdMob Pro plugin, or the Pro Bundle.

Okay but the plugin costs 199$ / year, that is way too much, i want to make money with ads and dont lose money for the plugin…

In the post it says “Note that your apps currently available in various app marketplaces will continue to serve ads — this only impacts new builds and updates starting on March 1.” 

My project is older then that, did this mean that i still can use the legacy AdMob plugin? The legacy AdMob plugin works for me but i need to wait a lot of hours.

No, you cannot update an existing project using the legacy AdMob plugin no matter how old the project may be.

But how are my ads then still working?

What that means is if you have an App in the store already using AdMob and you never update date it, it will continue to serve ads. If you want to update it, you will either have to use the paid AdMob plugin or consider using Appodeal which has AdMob included in its mediation and links to your existing AdMob account.  Appodeal is free for you to use.

Rob

@Rob Miracle do you have any experience what the best free ad network for corona is?

It all depends on what you’re looking to implement. I’d probably recommend different plugins depending on if you want banners or rewardedVideo. You might want to start with Appodeal.

Rob

If you are using banners Appodeal will produce the highest fill of the free ones. As for interstatial I like AppLovin even with the 5% tax. They consistently outperform any ad network that I have tried.

I haven’t ran the code, but in your show call you set “x” to the width of the display, which will surely put the ad ( as that’s the left position of the ad ) off screen?

Try setting that to 0. Also make sure the “y” value is correct, as a test set that to 0 as well.

@ajaks,

Can you post your build.settings file, please?

When you use the word ‘_ code _’:
 

 but everytime i change my [u][b]code[/b][/u], the ad will not be shown for a lot of hours. Is that normal?

  
Do you mean the Lua code.  Or do you mean the mean the ad campaign apID?

Also, if that’s your actual code, you’re calling .show() immediately after .init() which for many of our plugins is an asynchronous operation meaning it starts the init process in the background because it can take some time and you don’t want to block the app. I’m unsure about the AdMob plugin, but there is a good chance you’re calling .show() before .init() finishes.

Now if you’re .show() is reasonably delayed and you just pasted the code in to show us, then that’s probably not the answer.

Rob

In AdMobs its not possible to put Ads off the screen, thats why the y is that big, it puts the Ad to the bottom of the app.

Sure, here it is:

settings = { orientation = { default = "landscapeLeft", supported = { "landscapeRight", "landscapeLeft" } }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, googlePlayGamesAppId = "(here is a app id)", --largeHeap = true }, plugins = { -- key is the name passed to Lua's 'require()' ["plugin.google.iap.v3"] = { -- required publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, -- Google play game services ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, ["CoronaProvider.gameNetwork.apple"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, ["iphone-sim"]=true }, }, }, iphone = { plist = { CFBundleIconFiles = { "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-40@3x.png", }, UILaunchImages = { { --iPhone 4 Portait ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{320, 480}" }, { --iPhone 4 LandscapeLeft ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{320, 480}" }, { --iPhone 4 LandscapeRight ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{320, 480}" }, { --iPhone 5 Portait ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{320, 568}" }, { --iPhone 5 LandscapeLeft ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{320, 568}" }, { --iPhone 5 LandscapeRight ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-568h", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{320, 568}" }, { -- iPad / iPad Retina ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-Portrait", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{768, 1024}" }, { -- iPad / iPad Retina ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-Landscape", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{768, 1024}" }, { -- iPad / iPad Retina ["UILaunchImageMinimumOSVersion"] = "7.0", ["UILaunchImageName"] = "Default-Landscape", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{768, 1024}" }, { --iPhone 6 Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{375, 667}" }, { --iPhone 6 LandscapeLeft ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{375, 667}" }, { --iPhone 6 LandscapeRight ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-667h", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{375, 667}" }, { -- iPhone 6 Plus Portrait ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-736h", ["UILaunchImageOrientation"] = "Portrait", ["UILaunchImageSize"] = "{414, 736}" }, { -- iPhone 6 Plus landscape left ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-Landscape-736h", ["UILaunchImageOrientation"] = "LandscapeLeft", ["UILaunchImageSize"] = "{414, 736}" }, { -- iPhone 6 Plus landscape right ["UILaunchImageMinimumOSVersion"] = "8.0", ["UILaunchImageName"] = "Default-Landscape-736h", ["UILaunchImageOrientation"] = "LandscapeRight", ["UILaunchImageSize"] = "{414, 736}" } }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work --[[FacebookAppID = "XXXXXXXXXXXXXXXX", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXXXXXXX", -- replace XXXXXXXXX with your facebook appId } } }, --]] --[[UIAppFonts = { "immortal.ttf", "district.ttf", "carbontype.ttf", "Agency.ttf", "AgencyFB-Bold.ttf", }, --]] } }, excludeFiles = { iphone = { 'Icon-\*dpi.png', 'audio/\*.oog' }, android = { 'Icon.png', 'Icon-6\*.png', 'Icon-7\*.png', 'Icon-Small\*.png', 'Icon@2x.png', 'Default-568h@2x.png', 'audio/\*.m4a' } }, }