ADMOB, integrate both banner and interstitual issue

i cant acquire ads library because i get this error

error msg:

 

Runtime error

        F:\Android app development\The Red Airship\main.lua:22: module ‘ads’ not

 found:resource (ads.lu) does not exist in archive

        no field package.preload[‘ads’]

        no file ‘F:\Android app development\The Red Airship\ads.lua’

        no file 'G:\Program FRuntime error: F:\Android app development\The Red A

irship\main.lua:22: module ‘ads’ not found:resource (ads.lu) does not exist in archive

 

 

I cant find ads.lua file anywhere.Please help me getting it. Thanks in advance 

Here is the example and the console log. Still same problem:

[lua]

– require controller module

local ads = require “ads”

– Admob configuration

local BannerAppID = “ca-app-pub-4703317686453462/XXXXXX” --Banner

local InterstitialAppID = “ca-app-pub-4703317686453462/YYYYYYYY” --Interstitial

print ("-- Starting …")

– Set up ad listener.

local function adListener( event )  

        print ("-- adListener:", event.type)

end

– Initialize the ‘ads’ library with the provider you wish to use.

print ("-- Showing banner")

ads.init( “admob”, BannerAppID,adListener )

ads.show( “banner”, { x=display.screenOriginX, y=display.contentHeight-display.screenOriginY-120,appID=“ca-app-pub-4703317686453462/XXXXXXXXX” } )

local function showInterstitial()  

    print("-- showInterstitial function")

    ads.show( “interstitial”, { appID=“ca-app-pub-4703317686453462/YYYYYYYY” } )

end

timer.performWithDelay(5000, showInterstitial, 1)

[/lua]

Console log(with a WARNING):

V/Corona  (31018): > Class.forName: network.LuaLoader
V/Corona  (31018): < Class.forName: network.LuaLoader
V/Corona  (31018): Loading via reflection: network.LuaLoader
I/Corona  (31018): Platform: GT-I9100P / ARM Neon / 4.1.2 / Mali-400 MP / OpenGL ES 2.0 / 2014.2373
V/Corona  (31018): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  (31018): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  (31018): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
I/Corona  (31018): – Starting …
I/Corona  (31018): – Showing banner
V/Corona  (31018): > Class.forName: CoronaProvider.ads.admob.LuaLoader
V/Corona  (31018): < Class.forName: CoronaProvider.ads.admob.LuaLoader
V/Corona  (31018): Loading via reflection: CoronaProvider.ads.admob.LuaLoader
I/Corona  (31018): [Lua::RuntimeDispatchEvent()] WARNING: This function is deprecated. Use Lua::DispatchRuntimeEvent() instead.
I/Corona  (31018): – showInterstitial function
I/Corona  (31018): – adListener:       interstitial
I/Corona  (31018): – adListener:       banner
I/Corona  (31018): – adListener:       banner

That looks to me like it’s working.  Your banner ads are probably set to cycle every so often.  You might want to call ads.hide() before you call the interstitial.

Rob

I’ve had lots of problems with this, it works then stops working, and is very flakey.  The problem is there is no callback for when the interstitial has been closed.

Right now the ads are very unreliable on device when trying to use both.  Sometimes they both work, sometimes one works but not the other, sometimes neither, sometimes one works then disappears for minutes before it comes back even though you refreshed it a few times in that period.

If you run either alone, it’s mostly fine, but together it’s a disaster.

There is a call back when the ad closes.  See:  http://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/

Rob

Was this recently added?  I struggled with admob with Corona for a while, and did switch to v2 and was too inconsistent.  Been wanting to add ads to my old corona apps but want to show both.  I didn’t see a callback for it before.  I skimmed that page and I see there is a callback for when shown and I’ll give that a try.  I pocketed your recent article on v2 Admob, just never got around to reading it as I am mostly using Unity now.

By the way, Thanks!  That will allow me to revisit this and knock them out if it works well.

Yes, it was recently added.

Very interesting thread since I had the same issue with showing adMob interstitials and banners in the same app when initialising several ad providers (e.g. admob together with inneractive and vungle). I followed “jodiewilliams” advice above and it works perfectly this way. For some reasons, the tutorial here does not work for me at all. 

Interestingly, if I only initialise adMob and no other ad provider, I can use both banner and interstitial ads. If I initialise additional ad providers, this fails. When printing the event.response to the console adMob says that the ad request was successful but could not be fulfilled because of a lack of inventory. Still, if I use the method as describe by “jodiewilliams” above, all works fine.

A bug in Corona?

Here is how i finally managed to show both ads (banner and intertitial):

I have initialized the ads.show function with the following number: “ca-app-pub-4703317686453462/X” (literally), that is: ads.init( “admob”, “ca-app-pub-4703317686453462/X”,adListener )

and I have used my different codes for banner an interstitial as follows:

[lua]

local ads = require "ads"

    – Admob configuration

    local BannerAppID = “ca-app-pub-4703317686453462/3275893837” --Banner

    local InterstitialAppID = “ca-app-pub-4703317686453462/4752627031” --Interstitial

    print ("-- Starting …")

    

    local splashScreen=display.newImage (“imagen.jpg”)

    splashScreen.x=display.contentWidth/2

    splashScreen.y=display.contentHeight/2

    

    – Set up ad listener.

    local function adListener( event ) 

            print ("-- adListener:", event.type)

    end

    – Initialize the ‘ads’ library with the provider you wish to use.

    print ("-- Showing banner")

    ads.init( “admob”, “ca-app-pub-4703317686453462/X”,adListener )

    ads.show( “banner”, { x=display.screenOriginX, y=display.contentHeight-display.screenOriginY-60,appID=“ca-app-pub-4703317686453462/3275893837” } )

    

    local function showInterstitial() 

        print("-- showInterstitial function")

        ads.show( “interstitial”, { appID=“ca-app-pub-4703317686453462/4752627031” } )

    end

    timer.performWithDelay(1000, showInterstitial, 1)

[/lua]

 

From my personal point of view there is a mistake in the init function of the admob plugin.

 

I’ve also noticed the interstitial ad is shown after the banner ad is loaded and usually takes a long time the first time, so I suspect that that can be improved.

I figured it out!!

The problem whit this tutorial  (and also for most of us) is that when we show the ads we write a table name wrongly, the tutorial says that when showing the ads you should put the appID but the name of the table attribute is " appId". After that my code just works perfectly. Hope everyone can read this and fix the code. Also, Rob, please fix the tutorial. 

Hi HyperBeard Games, I am not sure if I can follow you completely. Does this apply to both initialising and showing the ads? Could you please post an example? This would be greatly appreciated.

Sure, let me explain. When you 

this is how you init: 

ads.init( "admob", "ca-app-pub-XXXXXX/XXXXXXX")

it doesn’t matter if you initialize with the banners or the interstitial 

now, this is how you show:

local interstitialID = "ca-app-pub-XXXXXXXXXXXX/XXXXXXXXXX" local bannerID = "ca-app-pub-XXXXXXXXXXXX/XXXXXXXXXX" if showInterstitials then ads.show("interstitial", {appId= interstitialID}) else ads.show( "banner", { x=0, y=0 , interval=10, appId = bannerID}) end

what is really important here is to remember that the table value appId  is not spelled appID. I saw that most of the code pasted here and the tutorial have this error.

Good catch! 

This has been fixed.

Rob

Thank you!

Great, works for me, too - thank you for pointing this out!

It doesn’t work.  
If fires for both banner (just showing a banner causes it to fire) and closing interstitial.

If you are just doing interstitial it works fine, but when doing both the banner ad causes it to fire too.

It would be really nice if this can actually get fixed.

Is it a problem that you get a call back when a banner ad shows?

[quote name=“Rob Miracle” post=“258652” timestamp=“1406943822”]Is it a problem that you get a call back when a banner ad shows?[/quote] Yes

Why not set a flag if you’re showing a banner or insterstitial and if you don’t care about the banner:

if adType == “banner” then

     return true

end

[quote name=“Rob Miracle” post=“258655” timestamp=“1406944248”]Why not set a flag if you’re showing a banner or insterstitial and if you don’t care about the banner:   if adType == “banner” then      return true end[/quote] Cause it is only suppose to fire when it is an interstitial, so it should work without additional monkeying. There should be a reliable way to know if the interstitial is closed. I am trying to use both, I close the banner with hide before calling interstitial (I know it does this already just prefer explicit) and then call banner when it is closed. Been asking for a solution for over a year, when it is added it is bugged.