AppID for new AdMob (April 2014)

Hi Guys,

I’ve created a story app which I am adding admob to.

I have placed in each .lua page, the following to handle admob:

display.setStatusBar( display.HiddenStatusBar )

local adNetwork = "admob"

local appID = "Just My Book Title"

local ads = require "ads"

if appID then

 ads.init( adNetwork, “ca-app-pub-xxxxxxxxxxxxxxxxxxxxx/XXXXXXXXX” )

end

.

.

.

then further down the page I use the following to try and show a banner.

ads.show( “banner”, { x=adX, y=adY, testMode=true} )

The simulator has no issue with this setup, except to tell me to “build” for a device to test it.

Unfortunately, when I build and transfer the apk to my Android phone, install and run, no ad appears.

My biggest uncertainty is that I cannot locate an AppID on my admob account, which is why I have just used my book title for “local appID”, and hardcoded the Ad unit ID into the “ads.init” request.  

The only two numbers that admob website shows is the Ad unit ID for each Ad you create, and the Publisher ID that is given in the top right hand corner of your account.  

I also noticed the Publisher ID you are assigned is integrated as part of your Ad unit ID.  But neither of these appear to be the AppID that older posts and threads seem to reference.

Also, regarding build.settings , I have added the following in it for admob.

_         plugins = _

_         { _

            [“CoronaProvider.ads.iads”] =

_                { _

_                 publisherId = “com.coronalabs”, _

_                 supportedPlatforms = { iphone = true }, _

_                }, _

_     _

               [“CoronaProvider.ads.admob”] =

_                { _

_                   publisherId = “com.coronalabs”, _

_                   supportedPlatforms = { android = true }, _

_                }, _

_         }, _

I’m not sure if what I have done is correct and/or if there is anything missing.  I have excluded an event listener as the guide I followed did not have one.  Let me know if you have any ideas.

Many Thanks,

R. :slight_smile:

First, you only need to init the ads once.  Do it in your main.lua.  Then in your modules where you need them, at the top, just do:

local ads = require(“ads”)

and then call ads.show() where you need the the ad to show.

As for setting up ads, this is the base code you need to work:

local provider = "admob" local appID = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxx/XXXXXXXXX" local ads = require "ads"   local function adListener( event )     -- event table includes:     --         event.provider     --        event.isError (e.g. true/false )          local msg = event.response     -- just a quick debug message to check what response we got from the library     print("Message received from the ads library: ", msg)     if event.isError then        -- handle no ad condition here     else         -- handle good ad condition here.     end end   if appID then     ads.init( provider, appID, adListener ) end   Then the show call is simply:   ads.show( "banner", { x=0, y=0 } )

If  you don’t get ads, you need to look through your adb logcat log to see what messages you are getting from the system.  If you don’t know how to do that, then read this tutorial:  http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Beyond that, it’s your responsibility to make sure  your settings on AdMob are correct.

Rob

Hi Rob,

Thank you for the prompt reply mate.  Did everything you said.

So right now I have the following:

  • _ build.settings _ has the plugin info as my original post.
  • _ main.lua _ has basically a cut and paste of what you posted above, minus the last 2 lines, and with my ad unit id inserted.
  • _ page-xx.lua _ simply have local ads = require(“ads”), followed by ads.show( “banner”, { x=0, y=0 } )

I also downloaded Android SDK Manager, and got adb up and running.

Currently when I start the app I get the following:

V/Corona  (11306): > Class.forName: network.LuaLoader

V/Corona  (11306): < Class.forName: network.LuaLoader

V/Corona  (11306): Loading via reflection: network.LuaLoader

V/Corona  (11306): > Class.forName: CoronaProvider.licensing.google.LuaLoader

V/Corona  (11306): < Class.forName: CoronaProvider.licensing.google.LuaLoader

V/Corona  (11306): Loading via reflection: CoronaProvider.licensing.google.LuaLo

ader

I/Corona  (11306): -----------------------------------------------

V/Corona  (11306): > Class.forName: CoronaProvider.ads.admob.LuaLoader

V/Corona  (11306): < Class.forName: CoronaProvider.ads.admob.LuaLoader

V/Corona  (11306): Loading via reflection: CoronaProvider.ads.admob.LuaLoader

And when I got a story page with the ads.show in it, I get the following:

I/Corona  (11306): Message received from the ads library:       A network error occurred.

The message continues to appear every 1-2 minutes.  Let me know your thoughts.

I’ll go check the forum for possible clues.  

Thanks for the support,

Cheers, R. :slight_smile:

First, you only need to init the ads once.  Do it in your main.lua.  Then in your modules where you need them, at the top, just do:

local ads = require(“ads”)

and then call ads.show() where you need the the ad to show.

As for setting up ads, this is the base code you need to work:

local provider = "admob" local appID = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxx/XXXXXXXXX" local ads = require "ads" &nbsp; local function adListener( event ) &nbsp;&nbsp; &nbsp;-- event table includes: &nbsp;&nbsp; &nbsp;-- &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;event.provider &nbsp;&nbsp; &nbsp;--&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;event.isError (e.g. true/false ) &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;local msg = event.response &nbsp;&nbsp; &nbsp;-- just a quick debug message to check what response we got from the library &nbsp;&nbsp; &nbsp;print("Message received from the ads library: ", msg) &nbsp;&nbsp; &nbsp;if event.isError then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -- handle no ad condition here &nbsp;&nbsp; &nbsp;else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- handle good ad condition here. &nbsp;&nbsp;&nbsp; end end &nbsp; if appID then &nbsp;&nbsp; &nbsp;ads.init( provider, appID, adListener ) end &nbsp; Then the show call is simply: &nbsp; ads.show( "banner", { x=0, y=0 } )

If  you don’t get ads, you need to look through your adb logcat log to see what messages you are getting from the system.  If you don’t know how to do that, then read this tutorial:  http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Beyond that, it’s your responsibility to make sure  your settings on AdMob are correct.

Rob

Hi Rob,

Thank you for the prompt reply mate.  Did everything you said.

So right now I have the following:

  • _ build.settings _ has the plugin info as my original post.
  • _ main.lua _ has basically a cut and paste of what you posted above, minus the last 2 lines, and with my ad unit id inserted.
  • _ page-xx.lua _ simply have local ads = require(“ads”), followed by ads.show( “banner”, { x=0, y=0 } )

I also downloaded Android SDK Manager, and got adb up and running.

Currently when I start the app I get the following:

V/Corona  (11306): > Class.forName: network.LuaLoader

V/Corona  (11306): < Class.forName: network.LuaLoader

V/Corona  (11306): Loading via reflection: network.LuaLoader

V/Corona  (11306): > Class.forName: CoronaProvider.licensing.google.LuaLoader

V/Corona  (11306): < Class.forName: CoronaProvider.licensing.google.LuaLoader

V/Corona  (11306): Loading via reflection: CoronaProvider.licensing.google.LuaLo

ader

I/Corona  (11306): -----------------------------------------------

V/Corona  (11306): > Class.forName: CoronaProvider.ads.admob.LuaLoader

V/Corona  (11306): < Class.forName: CoronaProvider.ads.admob.LuaLoader

V/Corona  (11306): Loading via reflection: CoronaProvider.ads.admob.LuaLoader

And when I got a story page with the ads.show in it, I get the following:

I/Corona  (11306): Message received from the ads library:       A network error occurred.

The message continues to appear every 1-2 minutes.  Let me know your thoughts.

I’ll go check the forum for possible clues.  

Thanks for the support,

Cheers, R. :slight_smile: