Is your app really at a point you need to add in Ads? I would consider this one of the last things you want to add in because you will be seeing them as you develop your app. You seem to have multiple apps in production so it’s really hard to judge where you are with them.
Now that said, you do have a problem in main.lua. You try to tell the .init() function about your listener function when it doesn’t exist yet. Remember Lua is a one pass compiler and you have to define/write things before you can address them. This is that pesky “scope” issue.
local appodeal = require( "plugin.appodeal" ) local json = require( "json" ) local composer = require( "composer" ) local function adListener( event ) print( json.prettify( event ) ) if ( event.phase == "init" ) then -- Successful initialization -- Show a banner ad composer.setVariable( "adsReady", true ) elseif ( event.phase == "failed" ) then -- The ad failed to load print( event.type ) print( event.isError ) print( event.response ) end end appodeal.init( adListener, { appKey="09e6c681ff134a85e448de94d693efa0fbbe231bca7d0e40", testMode=true} ) composer.gotoScene("start")
Notice how I changed the order of the adListener function and the .init(). I also added in a print statement to dump the results of the event table to the console log so you can see what errors you’re getting.
Your code jumps immediately to “start.lua”. There is a good chance that appodeal.init() isn’t finished yet and you won’t be able to show an ad until it completes. Do you really want a full screen ad to be the very first thing your users see? Or are you just trying to build a test case?
I also moved requiring Composer to the top. You should really try and group all your requires at the top of your code. By doing this I can use composer.setVariable() to define a variable that will let your other scenes know when initialization is complete.
Your start scene really needs to do some work before you start trying to load and show ads.
Lets make these changes and see what messages are printing to your console.log.
Rob