Problem with admob-v2 and banner ads

Hi @LsVtecTurbo95.  First, welcome to the forums.  I know your first post was moderated (and the forums should have told you it was moderated), but we do not permit the same question to be asked multiple times.  I’ve done what I can to clean up your extra posts.

Next, when posting code, please Copy/Paste the code and put it in between and brackets (remove the space after the ['s).  This will make it easier for the community to read your code.  I also believe I answered the same question in the blog post comments.  For those not seeing the blog post, the proper build.settings code would be:

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

Rob

I already have that in my code and my banner ads still don’t appear.

You said you have this:

plugins = {     ["plugin.google.play.services"] =     {         pub-8347067101481503 = “com.coronalabs”     }, },

not:   publisherId = “com.coronalabs”

I also cannot tell from above if you have two separate files or just one.  The first part is your build.settings, the other part is your main.lua.  But it would be really helpful if your code was formatted to be more readable.

this is my main.lua code;

local composer = require( “composer” )

display.setStatusBar(display.HiddenStatusBar)

_G.prefLib = require “prefLib”

_G.adsLib = require “adsLib”

_G.networksLib = require “networksLib”;

local activeNetworksProviders = {

  [“Android”] = {“google”, “CgkIhNyInMgZEAIQAQ”}, 

  [“iPhone OS”] = {“gamecenter”, “CgkIhNyInMgZEAIQAQ”} --replace “gamecenter” with “none” if you don’t use any leaderboard!

};

–networksLib.init(activeNetworksProviders);

– For in game Ad’s use this table and call

local activeAdsProviders = {

  [“Android”] = {“chartboost”,“admob”,“revmob”},

  [“iPhone OS”] = {“chartboost”,“admob”,“revmob”},

};

adsLib.init(activeAdsProviders); 

local ads = require( “ads” )

local bannerAppID = “ca-app-pub-8347067101481503/4080572917”  --for your iOS banner

if ( system.getInfo( “platformName” ) == “Android” ) then

    bannerAppID = “ca-app-pub-8347067101481503/2335507715”  --for your Android banner

end

local adProvider = “admob”

local function adListener( event )

    --(more on this later)

end

ads.show( adtype, table_of_parameters )

ads.show( “banner”, { x=0, y=0, appId=bannerAppID } )

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 )

    else

        print( “Ah ha! Got one!” )

    end

end

ads.init( adProvider, appID, adListener )

ads.show( “banner”, { x=0, y=0 } )

—===================sound related tasks

_G.musicChannel = 1;

audio.reserveChannels(1);

–and let’s immediately set the volume to the values saved throughout plays

local m = prefLib.getSaveValue(“musicVolume”) or .3

prefLib.setSaveValue(“musicVolume”,m,true)

audio.setVolume(m, {channel = _G.musicChannel});

for i = 2, audio.totalChannels do

local s = _G.prefLib.getSaveValue(“sfxVolume”) or 1

prefLib.setSaveValue(“sfxVolume”,s,true)

audio.setVolume(s, {channel = i});

end

–also, we’re going to use this sound everywhere, so I’ll load it here as a global variable once

_G.splashSFX = audio.loadSound(“sounds/splash.mp3”);

_G.clickSFX = audio.loadSound(“sounds/click.wav”);

_G.fireSFX = audio.loadSound(“sounds/spring.wav”);

_G.jumpSFX = audio.loadSound(“sounds/jump.wav”);

_G.rocketSFX = audio.loadSound(“sounds/rocket.wav”);

_G.fallSFX = audio.loadSound(“sounds/fall.wav”);

_G.coinSFX = audio.loadSound(“sounds/coin.mp3”);

audio.play(splashSFX, {channel = audio.findFreeChannel()});

– Later…

local img = display.newImageRect(“assets/Splash Screen1.jpg”,640,1136)

img.x = display.contentWidth/2

img.y = display.contentHeight/2

local function move()

display.remove(img);img = nil

composer.gotoScene( “homescene”,“fade”,1500 )

end

timer.performWithDelay(4000,move,1)

Well this block of code isn’t going to work, so you can remove it as you do things below it:

local function adListener( event )     --(more on this later) end   ads.show( adtype, table\_of\_parameters )   ads.show( "banner", { x=0, y=0, appId=bannerAppID } )

I did this. Still no banner ads. How can I fix this to were they show?

Any thought on this?

Can you make the ads example work in the Samples ? If so, can you convert it to Admob ?

Can you please tell me what you mean?

On the simulator there’s an ads sample.

You’re setting bannerAppID and using it as an option to ads.show(). This should be an option to ads.init().

Can you please look at my code and help me fix it? My banner ads are still not showing up.

local composer = require( "composer" ) display.setStatusBar(display.HiddenStatusBar) \_G.prefLib = require "prefLib" \_G.adsLib = require "adsLib" \_G.networksLib = require "networksLib"; local activeNetworksProviders = { ["Android"] = {"google", "CgkIhNyInMgZEAIQAQ"}, ["iPhone OS"] = {"gamecenter", "CgkIhNyInMgZEAIQAQ"} --replace "gamecenter" with "none" if you don't use any leaderboard! }; --networksLib.init(activeNetworksProviders); -- For in game Ad's use this table and call local activeAdsProviders = { ["Android"] = {"chartboost","admob","revmob"}, ["iPhone OS"] = {"chartboost","admob","revmob"}, }; adsLib.init(activeAdsProviders); ---===================sound related tasks \_G.musicChannel = 1; audio.reserveChannels(1); --and let's immediately set the volume to the values saved throughout plays local m = prefLib.getSaveValue("musicVolume") or .3 prefLib.setSaveValue("musicVolume",m,true) audio.setVolume(m, {channel = \_G.musicChannel}); for i = 2, audio.totalChannels do local s = \_G.prefLib.getSaveValue("sfxVolume") or .5 prefLib.setSaveValue("sfxVolume",s,true) audio.setVolume(s, {channel = i}); end --also, we're going to use this sound everywhere, so I'll load it here as a global variable once \_G.splashSFX = audio.loadStream("sounds/splash.mp3"); \_G.clickSFX = audio.loadSound("sounds/click.wav"); \_G.fireSFX = audio.loadSound("sounds/spring.wav"); \_G.jumpSFX = audio.loadSound("sounds/jump.wav"); \_G.rocketSFX = audio.loadSound("sounds/rocket.wav"); \_G.fallSFX = audio.loadSound("sounds/fall.wav"); \_G.coinSFX = audio.loadSound("sounds/coin.mp3"); \_G.gunShot = audio.loadSound("sounds/gunshot.mp3"); audio.play(splashSFX, {channel = audio.findFreeChannel()}); -- Later... local img = display.newImageRect("assets/Splash Screen1.jpg",640,1136) img.x = display.contentWidth/2 img.y = display.contentHeight/2 local function move() display.remove(img);img = nil composer.gotoScene( "homescene","fade",1500 ) end timer.performWithDelay(4000,move,1)

Thank you all for your help.

Can you please look at my code and help me fix it? My banner ads are still not showing up.

My Build.Setting code incase this my be the problem, please help me fix this error.

-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { plugins = { ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true } }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, ["CoronaProvider.gameNetwork.google"] = { --required! publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["facebook"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true}, }, }, orientation = { default = "portrait", supported = { "portrait", } }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", }, }, iphone = { plist = { UIAppFonts = { "QuentinCaps.ttf", }, UIViewControllerBasedStatusBarAppearance = false, UIStatusBarHidden = true, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work FacebookAppID = "329435700566704", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fb329435700566704", -- replace XXXXXXXXX with your facebook appId, make sure that you leave fb in front of "app910588198" } } } } }, }

Your build.setting doesn’t look correct. Are you trying to include both the iAds and admob plugins? It should look like this:

[lua]

plugins =

        {

                [“CoronaProvider.ads.iads”] =

                {

                        publisherId = “com.coronalabs”,

                        supportedPlatforms = { iphone=true },

                },

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

                        {

                        publisherId = “com.coronalabs”

                },

       },

[/lua]

It looks like you are trying to use this adsLib to setup multiple ad networks. Is this something you wrote yourself or did you get it from someone else? Did it come with any info on how to set it up correctly.

You have chartboost listed as an ad network, but you don’t include the chartboost plugin. 

I would suggest you narrow down the problem by just using admob as an active provider. Once you get that working, then add the other networks back in.

 Only Admob, my dev wrote this for me. Can you please fix this error for me and send me the correct code? Also how did my other code look?

@LsVtechTurbo95, please take time and try to understand the code you are writing.  You said “your dev wrote this for you”.  Does that mean someone else is programming this? 

I’m going to try and explain this.  Please read the code and the comments I’m posting and understand what you should do.  Do not just copy/paste this.

    plugins = { -- -- This plugin is for AdMob V1 and should be removed as Google does not allow it to be used any more. --         ["CoronaProvider.ads.admob"] =        {             publisherId = "com.coronalabs",             supportedPlatforms = { iphone=true }         }, --     --  This is the plugin for AdMob V2 --         ["plugin.google.play.services"] =         {              publisherId = "com.coronalabs",              supportedPlatforms = { android=true },  -- are you just building for Android or are you building for iOS?  If you're building for both, remove this line.  Without it, AdMob will only work on Android.          },                  ["CoronaProvider.gameNetwork.google"] =         {             --required!             publisherId = "com.coronalabs",             supportedPlatforms = { android=true }          },              ["facebook"] =         {              publisherId = "com.coronalabs",              supportedPlatforms = { iphone=true},   -- Are you only using Facebook on iOS?  If you want to use Facebook on Android, remove this line.  Assuming you're building with 2393 or later.  Facebook is now a plugin for Android.          },     },

Correct someone else is programming and developing the game for me. I’m trying my best. I have 8 other careers. 

I’m building for both iOS and android.