Any free ads plugin crashes the app?

Hello,

I’ve developed a game and try to monetize it. The problem is that if work perfectly on corona simulator, except throws warning: The ‘plugin.revmob’ library is not available on this platform. But it crashes on device, all ad companies causes app to stop working (I’ve tried inmobi, revmob, facebook audience network) YES, App-ID, and Placement-ID are correct I checked few times.

build.settings

-- -- For more information on build.settings see the Corona SDK Build Guide at: -- https://docs.coronalabs.com/guide/distribution/buildSettings -- settings = { orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", }, }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-167.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, }, }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_WIFI\_STATE", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE" }, }, plugins = { ["plugin.revmob"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=false, android=true } }, }, }

Ads implementation in menu.lua (NOT main.lua)

local revmob = require( "plugin.revmob" ) local placementID = "33\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*" local function adListener( event ) if ( event.phase == "sessionStarted" ) then revmob.load( "banner", placementID ) elseif ( event.phase == "loaded" ) then revmob.show( placementID, { yAlign="top" } ) end end function scene:create( event ) local sceneGroup = self.view revmob.init( adListener, { appId="77\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*" } ) ... more code ;D

What wrong am I doing? Please help! Your advice will be greatly appreciated!

You’ve not provided us enough information to really help you. There could be errors or warnings from other things. You need to look at the device’s console log to see what’s happening. Use this as a guide to help you debug your app:

https://docs.coronalabs.com/guide/basics/debugging/index.html

Now one problem is you really should only init an ad plugin once. I would put the .init call and the listener function in your main.lua and not have it in a scene. You would then still require the plugin in the scene but just call revmob.show(), .hide() and .load() as needed.

Rob

Here is my logcat from device, there is no reason to debug I think, because it works fine in simulator (works fine on device without freead.init() stuff) I don’t get it, so please help me:

https://pastebin.com/SJsxRPst

https://pastebin.com/EDSLLNvM

Now one problem is you really should only init an ad plugin once. I would put the .init call and the listener function in your main.lua and not have it in a scene. You would then still require the plugin in the scene but just call revmob.show(), .hide() and .load() as needed.

Now my Init and Listener is in main.lua but still I get same crash error.

P.s I haven’t uploaded my game on Google Play can this be a reason?

Can you capture the log again this time start capturing before you start your app and stop after the app stops working.  It might be helpful to put some print statements in your listener function like this:

local json = require("json") local function adListener( event ) print(json.prettify( event )) if ( event.phase == "sessionStarted" ) then revmob.load( "banner", placementID ) elseif ( event.phase == "loaded" ) then revmob.show( placementID, { yAlign="top" } ) end end

And post the entire log capture.

It will also help helpful for you current code where you initialize the ads.

Rob

Full debug: https://pastebin.com/h4GQ7Re7

V/Corona  ( 8690): > Class.forName: network.LuaLoader
V/Corona  ( 8690): < Class.forName: network.LuaLoader
V/Corona  ( 8690): Loading via reflection: network.LuaLoader
I/Corona  ( 8690): Platform: LG-P760 / ARM Neon / 4.0.4 / PowerVR SGX 540 / OpenGL ES 2.0 build 1.8@869593 / 2016.2992 / lietuvi┼│ | LT | lt_LT | lt
V/Corona  ( 8690): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  ( 8690): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  ( 8690): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
V/Corona  ( 8690): > Class.forName: plugin.revmob.LuaLoader
V/Corona  ( 8690): < Class.forName: plugin.revmob.LuaLoader
V/Corona  ( 8690): Loading via reflection: plugin.revmob.LuaLoader
I/Corona  ( 8690): App started
I/Corona  ( 8690): before init
I/Corona  ( 8690): after init

local json = require("json") print("App started") local function adListener( event ) &nbsp;print("DEBUG-X:"..json.prettify( event)) &nbsp;if ( event.phase == "sessionStarted" ) then &nbsp;revmob.load( "banner", placementID ) &nbsp; &nbsp;elseif ( event.phase == "loaded" ) then &nbsp;&nbsp;revmob.show( placementID, { yAlign="top" } ) &nbsp;end end print("before init") revmob.init( adListener, { appId="\*\*\*secret\*\*\*" } ) print("after init")

DEBUG-X did’t even show

I see that you’re using an old public build (2016.2992). A lot has changed with the Android build system and the plugins since then.

Please try again with the latest public build 2017.3068.

ingemar cl it works! thank you!

You’ve not provided us enough information to really help you. There could be errors or warnings from other things. You need to look at the device’s console log to see what’s happening. Use this as a guide to help you debug your app:

https://docs.coronalabs.com/guide/basics/debugging/index.html

Now one problem is you really should only init an ad plugin once. I would put the .init call and the listener function in your main.lua and not have it in a scene. You would then still require the plugin in the scene but just call revmob.show(), .hide() and .load() as needed.

Rob

Here is my logcat from device, there is no reason to debug I think, because it works fine in simulator (works fine on device without freead.init() stuff) I don’t get it, so please help me:

https://pastebin.com/SJsxRPst

https://pastebin.com/EDSLLNvM

Now one problem is you really should only init an ad plugin once. I would put the .init call and the listener function in your main.lua and not have it in a scene. You would then still require the plugin in the scene but just call revmob.show(), .hide() and .load() as needed.

Now my Init and Listener is in main.lua but still I get same crash error.

P.s I haven’t uploaded my game on Google Play can this be a reason?

Can you capture the log again this time start capturing before you start your app and stop after the app stops working.  It might be helpful to put some print statements in your listener function like this:

local json = require("json") local function adListener( event ) print(json.prettify( event )) if ( event.phase == "sessionStarted" ) then revmob.load( "banner", placementID ) elseif ( event.phase == "loaded" ) then revmob.show( placementID, { yAlign="top" } ) end end

And post the entire log capture.

It will also help helpful for you current code where you initialize the ads.

Rob

Full debug: https://pastebin.com/h4GQ7Re7

V/Corona  ( 8690): > Class.forName: network.LuaLoader
V/Corona  ( 8690): < Class.forName: network.LuaLoader
V/Corona  ( 8690): Loading via reflection: network.LuaLoader
I/Corona  ( 8690): Platform: LG-P760 / ARM Neon / 4.0.4 / PowerVR SGX 540 / OpenGL ES 2.0 build 1.8@869593 / 2016.2992 / lietuvi┼│ | LT | lt_LT | lt
V/Corona  ( 8690): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  ( 8690): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona  ( 8690): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
V/Corona  ( 8690): > Class.forName: plugin.revmob.LuaLoader
V/Corona  ( 8690): < Class.forName: plugin.revmob.LuaLoader
V/Corona  ( 8690): Loading via reflection: plugin.revmob.LuaLoader
I/Corona  ( 8690): App started
I/Corona  ( 8690): before init
I/Corona  ( 8690): after init

local json = require("json") print("App started") local function adListener( event ) &nbsp;print("DEBUG-X:"..json.prettify( event)) &nbsp;if ( event.phase == "sessionStarted" ) then &nbsp;revmob.load( "banner", placementID ) &nbsp; &nbsp;elseif ( event.phase == "loaded" ) then &nbsp;&nbsp;revmob.show( placementID, { yAlign="top" } ) &nbsp;end end print("before init") revmob.init( adListener, { appId="\*\*\*secret\*\*\*" } ) print("after init")

DEBUG-X did’t even show

I see that you’re using an old public build (2016.2992). A lot has changed with the Android build system and the plugins since then.

Please try again with the latest public build 2017.3068.

ingemar cl it works! thank you!