AdMob, Putting Ads

Hello. So I have been looking over the “Implementing AdMob V2” page on how to put Ads into my game. https://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/

But I have tried different kinds of ways to put it in, and it won’t work. For instance, build.settings. I don’t have a “plugins” table, and when I put one in, along with this code:
 

 plugins = { ["CoronaProvider.ads.admob"] = { publisherId = "(My Publisher ID here)", }, }, 

It won’t work… So what do I do or change?

I’m trying to figure this out as well.  But, in the tutorial you referenced, it indicates you should use the following:

plugins =

{

[“plugin.google.play.services”] =

{ publisherId = “com.coronalabs”

},

},

Hope that helps

Hello, So what you need to change is this

 plugins = { ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs" }, },

to this

 plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, },

Good Luck!

Well yes. The tutorial does say that. But there a link in the tutorial above that code showing you the AdMob plugins code, hence the:

CoronaProvider.ads.admob

I am very sure that this:

plugin.google.play.services

Is an example. Because that code is for google play services… Otherwise, leaderboards. So I am not too sure about it.

You can try this code out…

This goes in a main.lua…

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 bannerID = "ca-app-pub-xxx --put your id here.." local testMode = true local ads=require("ads") local function adListener( event ) for k,v in pairs( event ) do 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 = testMode } ) local function showAd( adPosition, isTestMode ) local xPos, yPos local adPosition = "bottom" if adPosition == "top" then xPos = display.screenOriginX yPos = top elseif adPosition == "bottom" then xPos = display.screenOriginX yPos = bottom end ads:setCurrentProvider("admob") ads.show( "banner", { x = xPos,y = yPos, appId = bannerID, testMode = isTestMode } ) end showAd( "top", testMode )

And heres the build.settings

settings = { plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", }, }, }

And heres config

application = { content = { width = 320, height = 480, scale = "letterbox", -- Best fps = 30, }, }

Good Luck!

– I DO NOT TAKE ANY CREDIT FOR THE CODE ITS ALL FROM @Roaminggamer

Can you provide me the link where it says to do CoronaProvider.ads.admob? I just checked the tutorial and all the links leaving from it and they all point to the correct plugin.google.play.services.

Rob

So on the Tutorial page for Implementing AdMob, under the section “Including the plugin” it has a link. The “Tutorial” link for “if this topic is unfamiliar”.

Link:

https://coronalabs.com/blog/2014/07/08/tutorial-understanding-build-settings/

Then under the “Plugins Table” the first code has the CoronaProvider.ads.admob code in there. So I thought that was the real code for the AdMob plugin. But I guess I was wrong.

You should always look at the plugins documentation to make sure you have the latest code. That tutorial was to teach you how to write a build.settings file and understand how it’s programmed. It wasn’t intended to teach you how to use AdMob. That’s why the tutorial linked to the AdMob documentation which is right.

I’ve updated it so it’s now correct.

Rob

Hello, I personally helped @Spid3rtech set up and work admob… So this topic is considered closed.

Thanks and Good Luck!

I’m trying to figure this out as well.  But, in the tutorial you referenced, it indicates you should use the following:

plugins =

{

[“plugin.google.play.services”] =

{ publisherId = “com.coronalabs”

},

},

Hope that helps

Hello, So what you need to change is this

 plugins = { ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs" }, },

to this

 plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, },

Good Luck!

Well yes. The tutorial does say that. But there a link in the tutorial above that code showing you the AdMob plugins code, hence the:

CoronaProvider.ads.admob

I am very sure that this:

plugin.google.play.services

Is an example. Because that code is for google play services… Otherwise, leaderboards. So I am not too sure about it.

You can try this code out…

This goes in a main.lua…

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 bannerID = "ca-app-pub-xxx --put your id here.." local testMode = true local ads=require("ads") local function adListener( event ) for k,v in pairs( event ) do 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 = testMode } ) local function showAd( adPosition, isTestMode ) local xPos, yPos local adPosition = "bottom" if adPosition == "top" then xPos = display.screenOriginX yPos = top elseif adPosition == "bottom" then xPos = display.screenOriginX yPos = bottom end ads:setCurrentProvider("admob") ads.show( "banner", { x = xPos,y = yPos, appId = bannerID, testMode = isTestMode } ) end showAd( "top", testMode )

And heres the build.settings

settings = { plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", }, }, }

And heres config

application = { content = { width = 320, height = 480, scale = "letterbox", -- Best fps = 30, }, }

Good Luck!

– I DO NOT TAKE ANY CREDIT FOR THE CODE ITS ALL FROM @Roaminggamer

Can you provide me the link where it says to do CoronaProvider.ads.admob? I just checked the tutorial and all the links leaving from it and they all point to the correct plugin.google.play.services.

Rob

So on the Tutorial page for Implementing AdMob, under the section “Including the plugin” it has a link. The “Tutorial” link for “if this topic is unfamiliar”.

Link:

https://coronalabs.com/blog/2014/07/08/tutorial-understanding-build-settings/

Then under the “Plugins Table” the first code has the CoronaProvider.ads.admob code in there. So I thought that was the real code for the AdMob plugin. But I guess I was wrong.

You should always look at the plugins documentation to make sure you have the latest code. That tutorial was to teach you how to write a build.settings file and understand how it’s programmed. It wasn’t intended to teach you how to use AdMob. That’s why the tutorial linked to the AdMob documentation which is right.

I’ve updated it so it’s now correct.

Rob

Hello, I personally helped @Spid3rtech set up and work admob… So this topic is considered closed.

Thanks and Good Luck!