ads init issue? unable to close ad

I recently created a new .apk and uploaded it to the Beta area in the Google Developer Console.  When I download the app and run it for the first time, I get an error (screenshot attached).  The error will go away the second or third time I run the app, but the Corona Ads within the game cannot be ‘closed’ - I have to use the back button as the ‘No’ option does not work.

I am wondering if this is somehow related to the new splash page, or an issue with the Ads plugin itself, or if the ads have something wrong, or if the permissions confirmation for the ads (location) is stopping the init…  I don’t know where to look.

I didn’t see any problems in the simulator, but do see the issue when I build for device - side loaded or from the Play Store.

Thanks!

Sounds like you’re not calling the .init() function correctly.  Can you post the code?

Rob

build.settings

[lua]

       [“plugin.coronaAds”] =

            {

                publisherId = “com.coronalabs”,

                supportedPlatforms = { android=true }

            },

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

            {

                publisherId = “com.coronalabs”,

                supportedPlatforms = { android=true }

            },

            [“shared.android.support.v4”] =

            {

                publisherId = “com.coronalabs”,

                supportedPlatforms = { android=true }

            },

    },

[/lua]

init in main.lua

[lua]

  corona = require( “plugin.coronaAds” )

– Corona Event listener function

local function CoronaListener( event )

    if ( event.phase == “init” ) then

        – corona system initialized

DATA.readytoshowAd = true

print(“coronaAds init-ed from main.lua”)

elseif ( event.phase == “found” ) then

elseif ( event.phase == “failed” ) then

DATA.screenshowncount = 4

elseif ( event.phase == “shown” ) or ( event.phase == “closed” ) then

DATA.screenshowncount = 1

    end

end

  corona.init( “fdsafdsa fdsa fdsa fdsa fdas fsad fdsa”, CoronaListener )

[/lua]

call for ad in scorescreen.lua

[lua]

coronaAds = require( “plugin.coronaAds” )

----- control the loading and display of ads, and show the buttons at the proper time

local showCoronaAds = function ()

print(“showCoronaAds called”)

local alert

if DATA.adPurchased == false then

if DATA.displayAds == true then

print(“in showCoronaAds function”)

– count every third cycle

if DATA.screenshowncount >= 4 and DATA.readytoshowAd == true and DATA.adProvider == “Corona” then

local adPlacement = “interstitial-1”

–local adPlacement = “top-banner-320x50”

–alert = native.showAlert( “Ad - to be shown”, "Ad is ready to be shown, placement = "…adPlacement, { “OK”, “Cancel” } )

coronaAds.show( adPlacement, true )

else

DATA.screenshowncount = DATA.screenshowncount + 1

–print("screenshowncount = "…DATA.screenshowncount)

timers.t10 = timer.performWithDelay(1000,showButtons)

end

end

elseif DATA.adPurchased == true then

print (“in the adPurchased area of showCoronaAds”)

–alert = native.showAlert( “Ad free”, “In the DATA.adPurchased == true condition”, { “OK”, “Cancel” } )

timers.t10 = timer.performWithDelay(1000,showButtons)

end

–alert = native.showAlert( “in showCoronaAds”, “no condition”, { “OK”, “Cancel” } )

alert = nil

end

timers.t9 = timer.performWithDelay(200,showCoronaAds)

[/lua]

Any ideas on this Rob?

Have you looked at the console log of your device?

If you need help with that, please read: https://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Do we have the latest Amob?

Now in their instructions says:

Follow the SDK integration guide. Specify ad type, size, and placement when you integrate the code.

  • App ID:  ca-app-pub-xxxxxxxxxxxxxxx~8562082240
  • Ad unit ID:  ca-app-pub-yyyyyyyyyyyyy/8422481443

DidDid we ever needed the first number?

WeWe always sended the second number right?

WhWhere is the first one used?

Sorry, now saw this is a wrong thread.

Should be about AdMob.

This thread is for a Corona Ads question. Please start a new thread to discuss the AdMob question.

Here is the output from the console log - it only crashes on the first run after the install.  I think that there might be something in my code throwing off the composer when the ‘permission window’ comes up - it can’s quite navigate around that (?), but once it is accepted and the system doesn’t ask for permissions, it runs ok.  

Note also, the ads are working ok now. They allow the ‘No’ button to be selected and the game resumes, so that might eliminate the question about the ad init being the issue.

--------- beginning of system 10-01 22:34:21.233 3082 3097 V Corona : \> Class.forName: network.LuaLoader 10-01 22:34:21.233 3082 3097 V Corona : \< Class.forName: network.LuaLoader 10-01 22:34:21.253 3082 3097 V Corona : Loading via reflection: network.LuaLoader 10-01 22:34:21.353 3082 3097 I Corona : Platform: SM-G900V / ARM Neon / 6.0.1 / Adreno (TM) 330 / OpenGL ES 3.0 V@140.0 AU@ (GIT@Ia10634f51b) / 2016.2935 / English | US | en\_US | en 10-01 22:34:21.523 3082 3097 V Corona : \> Class.forName: CoronaProvider.licensing.google.LuaLoader 10-01 22:34:21.523 3082 3097 V Corona : \< Class.forName: CoronaProvider.licensing.google.LuaLoader 10-01 22:34:21.993 3082 3097 V Corona : Loading via reflection: CoronaProvider.licensing.google.LuaLoader 10-01 22:34:22.373 3082 3097 V Corona : \> Class.forName: plugin.coronaAds.LuaLoader 10-01 22:34:22.403 3082 3097 V Corona : \< Class.forName: plugin.coronaAds.LuaLoader 10-01 22:34:22.413 3082 3097 V Corona : Loading via reflection: plugin.coronaAds.LuaLoader 10-01 22:34:22.413 3082 3097 V Corona : \> Class.forName: plugin.chartboost.LuaLoader 10-01 22:34:22.423 3082 3097 V Corona : \< Class.forName: plugin.chartboost.LuaLoader 10-01 22:34:22.423 3082 3097 V Corona : Loading via reflection: plugin.chartboost.LuaLoader 10-01 22:34:22.423 3082 3097 V Corona : \> Class.forName: CoronaProvider.ads.admob.LuaLoader 10-01 22:34:22.423 3082 3097 V Corona : \< Class.forName: CoronaProvider.ads.admob.LuaLoader 10-01 22:34:22.423 3082 3097 V Corona : Loading via reflection: CoronaProvider.ads.admob.LuaLoader 10-01 22:34:22.503 3082 3097 I Corona : plugin.chartboost: 1.0.1 10-01 22:34:22.783 3082 3097 I Corona : WARNING: audio.stop() called with nil. To stop all channels, call audio.stop() with no parameters 10-01 22:34:23.653 3082 3097 I Corona : save sound file 10-01 22:34:29.773 3082 3097 I Corona : ERROR: Runtime error 10-01 22:34:29.773 3082 3097 I Corona : /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/composer/composer.lua:1451: /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:762: bad argument #1 to 'find' (string expected, got nil) 10-01 22:34:29.773 3082 3097 I Corona : stack traceback: 10-01 22:34:29.773 3082 3097 I Corona : [C]: in function 'error' 10-01 22:34:29.773 3082 3097 I Corona : /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/composer/composer.lua:1451: in function 'gotoScene' 10-01 22:34:29.773 3082 3097 I Corona : ?: in function 'func' 10-01 22:34:29.773 3082 3097 I Corona : /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:186: in function \</Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:169\> 10-01 22:34:30.623 3082 3097 I Corona : save sound file

If you ran “adb logcat” with parameters that filter only on Corona messages, can you run it again leaving off any extra parameters? That is just type:

adb logcat

Thanks

Rob

I attached the log below - looking for ‘corona’ and/or ‘mathbenimble’ you can see the app launch and the issues that come up…

I have discovered that this is NOT necessarily a new issue for this app and may not be related to CoronaAds at all…  I found some crash reports dating back a few months that have the same type of issue.

Any luck? 

No, I’ve not found anything yet. Still researching.

Are you also trying to use Chartboost?

Also there is an error when trying to go to a scene (the Error I think you are actually seeing). The error is basically saying it can’t load the scene and not giving me a lot of other errors. Is that the full “showscores.lua” file?

No, I had the plugin called, but it is commented out in build.settings.  I was wondering why it is still getting loaded.  All chartboost code is commented out.

It is not the full showscores.lua file - see attached , but I was seeing the crash much before the showscores.lua was ever called.

Also attached is main.lua.  I am thinking that the code around the ‘resume’ of the app might be the problem, and the permissions window is entering into the condition for that - and then not handling it correctly. (specifically 191-195 where DATA.lastscene has not been set)

I’d look at the value of DATA.lastscene and make sure it’s what you’re expecting it to do. Also, you may just want to simply and on a resume goto the menu. Something to consider.

scoreScreen.lua is still loading the chartboost plugin.  

You can always add in “print” statements. I see you’re using native.showAlert() for your debugging… The prints will go to the console log so you can see what’s going on with out interrupting the apps flow.

Rob

I adjusted the logic in the applicationResume - it seems to do the trick.

As for the chartboost plugin - I guessed I missed the plugin call in the scorescreen.lua as i was trying to limit how much i had to change to re-enable it when I wanted.  It does make me wonder though, if calling the plugin is enough to install it, why the effort with the build.settings?  Then again, my code wasn’t working so maybe it isn’t a valid question…

I use print statements more often then alerts - in this case I was trying to kind of simulate an ad popping up and used the alert box only temporarily.

I am still playing, but I think that my issue here has been resolved.  I am not sure it was the ad.init, and the ‘ads not closing’ aspect of this issue has not resurfaced.  I also don’t think it had anything to do with the Corona splash image. Perhaps the tags and title of this post could be changed to better reflect the real issue - which I believe was the applicationResume after the permissions popup on the initial install and app start (and following starts if permissions were denied and the “do not ask again” box wasn’t checked) of the app.  Once I handled that in applicationResume, things seem to work ok.

Thanks once again Rob!

Glad you’re going. 

Rob

Sounds like you’re not calling the .init() function correctly.  Can you post the code?

Rob

build.settings

[lua]

       [“plugin.coronaAds”] =

            {

                publisherId = “com.coronalabs”,

                supportedPlatforms = { android=true }

            },

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

            {

                publisherId = “com.coronalabs”,

                supportedPlatforms = { android=true }

            },

            [“shared.android.support.v4”] =

            {

                publisherId = “com.coronalabs”,

                supportedPlatforms = { android=true }

            },

    },

[/lua]

init in main.lua

[lua]

  corona = require( “plugin.coronaAds” )

– Corona Event listener function

local function CoronaListener( event )

    if ( event.phase == “init” ) then

        – corona system initialized

DATA.readytoshowAd = true

print(“coronaAds init-ed from main.lua”)

elseif ( event.phase == “found” ) then

elseif ( event.phase == “failed” ) then

DATA.screenshowncount = 4

elseif ( event.phase == “shown” ) or ( event.phase == “closed” ) then

DATA.screenshowncount = 1

    end

end

  corona.init( “fdsafdsa fdsa fdsa fdsa fdas fsad fdsa”, CoronaListener )

[/lua]

call for ad in scorescreen.lua

[lua]

coronaAds = require( “plugin.coronaAds” )

----- control the loading and display of ads, and show the buttons at the proper time

local showCoronaAds = function ()

print(“showCoronaAds called”)

local alert

if DATA.adPurchased == false then

if DATA.displayAds == true then

print(“in showCoronaAds function”)

– count every third cycle

if DATA.screenshowncount >= 4 and DATA.readytoshowAd == true and DATA.adProvider == “Corona” then

local adPlacement = “interstitial-1”

–local adPlacement = “top-banner-320x50”

–alert = native.showAlert( “Ad - to be shown”, "Ad is ready to be shown, placement = "…adPlacement, { “OK”, “Cancel” } )

coronaAds.show( adPlacement, true )

else

DATA.screenshowncount = DATA.screenshowncount + 1

–print("screenshowncount = "…DATA.screenshowncount)

timers.t10 = timer.performWithDelay(1000,showButtons)

end

end

elseif DATA.adPurchased == true then

print (“in the adPurchased area of showCoronaAds”)

–alert = native.showAlert( “Ad free”, “In the DATA.adPurchased == true condition”, { “OK”, “Cancel” } )

timers.t10 = timer.performWithDelay(1000,showButtons)

end

–alert = native.showAlert( “in showCoronaAds”, “no condition”, { “OK”, “Cancel” } )

alert = nil

end

timers.t9 = timer.performWithDelay(200,showCoronaAds)

[/lua]

Any ideas on this Rob?