Google admob test ads are not showing up in device

This is the code i am using to display test banner ads, i deployed the app to physical device but can’t see any test ad  :mellow:

local ads=require("ads") local function adListener( event ) if ( event.isError ) then --Failed to receive an ad end end ads.init("admob","ca-app-pub-3940256099942544/6300978111",adListener) ads.show("banner",{x=100, y=120, appId="ca-app-pub-3940256099942544/6300978111"})

I am using the appId which is provided by google in their docs to see test ads, am i missing anything ? :frowning:

I don’t see you setting the test mode flag.  Do that for sure or you’ll get whacked by Google.

This is all the code I would use to show a banner ad (in test mode).

Note: My code is not actually laid out like this, I put it all together to show you the order of execution.

local unusedWidth     = display.actualContentWidth - display.contentWidth local unusedHeight    = display.actualContentHeight - display.contentHeight local left            = 0 - unusedWidth/2 local top             = 0 - unusedHeight/2 local right           = display.contentWidth + unusedWidth/2 local bottom          = display.contentHeight + unusedHeight/2 local ads=require("ads") local function adListener( event ) for k,v in pairs( event ) print("adListener ", k, v ) -- so you see everything you get end end ads.init("admob", bannerID, adListener ) ads:setCurrentProvider("admob") ads.load("admob", { appId = bannerID, testMode = true } ) local function showAd( adPosition, isTestMode ) local xPos, yPos local adPosition = "top" -- "top", "bottom" if adPosition == "top" then xPos, yPos = display.screenOriginX, top elseif adPosition == "bottom" then xPos, yPos = display.screenOriginX, bottom end ads:setCurrentProvider("admob") ads.show( "banner", { x = xPos, y = yPos, appId = bannerID, testMode = isTestMode } ) end showAd( "top", true )

Note: When I say “whacked” I mean you risk have your your AdSense and Google Developer account permanently closed if you are not careful about using test mode.

Always use test mode (if provided) when testing ad networks.

@roaming gamer besides a small mistake in your for statement your solution worked perfectly but when i want to show live ads what parameters do i need to change ?  btw i am getting smart banner test ad display on top of my device, does the size of the ad changes during live ads or stays the same length & width ? 

no matter whether i use showAd( “top”, true ) or showAd( “bottom”, true ) the ad is always showing up at the top, why is this ??  :mellow: even i changed this in local showad function  local adPosition = “bottom” but still the ad is always at the top.

re: for statement typo -  Yeah, sorry I make typos when I cut, paste and re-arrange code for answers in the forums. 

top vs bottom - I just noticed, my code (above) includes references to ssk variables (top and bottom).  Add this above your code and it will work:

local unusedWidth = display.actualContentWidth - display.contentWidth local unusedHeight = display.actualContentHeight - display.contentHeight local left = 0 - unusedWidth/2 local top = 0 - unusedHeight/2 local right = display.contentWidth + unusedWidth/2 local bottom = display.contentHeight + unusedHeight/2

re: smart banners - “Yes”, I think these resize based on platform.  Oh, and seeing that message means you’re getting a test ad, so you’re safe from Google pain and punishment. :slight_smile:

re: live ads - Be sure to supply a valid ad id and set testMode to false in the load and show statements.

@roaming gamer everything is perfect!! now,  thanx a lot!!  :smiley:

I don’t see you setting the test mode flag.  Do that for sure or you’ll get whacked by Google.

This is all the code I would use to show a banner ad (in test mode).

Note: My code is not actually laid out like this, I put it all together to show you the order of execution.

local unusedWidth     = display.actualContentWidth - display.contentWidth local unusedHeight    = display.actualContentHeight - display.contentHeight local left            = 0 - unusedWidth/2 local top             = 0 - unusedHeight/2 local right           = display.contentWidth + unusedWidth/2 local bottom          = display.contentHeight + unusedHeight/2 local ads=require("ads") local function adListener( event ) for k,v in pairs( event ) print("adListener ", k, v ) -- so you see everything you get end end ads.init("admob", bannerID, adListener ) ads:setCurrentProvider("admob") ads.load("admob", { appId = bannerID, testMode = true } ) local function showAd( adPosition, isTestMode ) local xPos, yPos local adPosition = "top" -- "top", "bottom" if adPosition == "top" then xPos, yPos = display.screenOriginX, top elseif adPosition == "bottom" then xPos, yPos = display.screenOriginX, bottom end ads:setCurrentProvider("admob") ads.show( "banner", { x = xPos, y = yPos, appId = bannerID, testMode = isTestMode } ) end showAd( "top", true )

Note: When I say “whacked” I mean you risk have your your AdSense and Google Developer account permanently closed if you are not careful about using test mode.

Always use test mode (if provided) when testing ad networks.

@roaming gamer besides a small mistake in your for statement your solution worked perfectly but when i want to show live ads what parameters do i need to change ?  btw i am getting smart banner test ad display on top of my device, does the size of the ad changes during live ads or stays the same length & width ? 

no matter whether i use showAd( “top”, true ) or showAd( “bottom”, true ) the ad is always showing up at the top, why is this ??  :mellow: even i changed this in local showad function  local adPosition = “bottom” but still the ad is always at the top.

re: for statement typo -  Yeah, sorry I make typos when I cut, paste and re-arrange code for answers in the forums. 

top vs bottom - I just noticed, my code (above) includes references to ssk variables (top and bottom).  Add this above your code and it will work:

local unusedWidth = display.actualContentWidth - display.contentWidth local unusedHeight = display.actualContentHeight - display.contentHeight local left = 0 - unusedWidth/2 local top = 0 - unusedHeight/2 local right = display.contentWidth + unusedWidth/2 local bottom = display.contentHeight + unusedHeight/2

re: smart banners - “Yes”, I think these resize based on platform.  Oh, and seeing that message means you’re getting a test ad, so you’re safe from Google pain and punishment. :slight_smile:

re: live ads - Be sure to supply a valid ad id and set testMode to false in the load and show statements.

@roaming gamer everything is perfect!! now,  thanx a lot!!  :smiley: