user3393310
user3393310

Reputation: 1

Error with admob in my Corona game

Hello I have tried to get admob to work in my game, but I can't figure it out. I've checked http://docs.coronalabs.com/guide/monetization/adSupport/index.html and admobs documentation but it's still not working, I have no idea where to put the code tbh, and I havent created a build.settings file. the current lua files I have is my main.lua, config.lua, mydata.lua, restart.lua, start.lua, score.lua and game.lua. I'm just wondering where i should put the code and what code to put where. would love to get an answer quickly as i have struggle with this for a month now...

Also do i need the build.settings? My game works perfecty on my phone and on the simulator but without ads that is...

So now i have this code in my build.settings:

settings =
plugins =
{
    -- key is the name passed to Lua's 'require()'
    ["CoronaProvider.ads.admob"] =
    {
        -- required
        publisherId = "com.coronalabs",
    },
},      
}

And this is my main.lua:

display.setStatusBar( display.HiddenStatusBar )
local storyboard = require "storyboard"
storyboard.gotoScene( "start" )


local ads = require "ads"

local function adListener( event )
    if event.isError then
        -- Failed to receive an ad.
    end
end

ads.init( "admob", "ca-app-pub-****", adListener )
ads.show( "banner", { x=0, y=5 } ) 

I still when I try to build it for android, an error occur saying: there is an error in your "build.settings" file. Please see the console output for more details. Don't know what that means

Upvotes: 0

Views: 894

Answers (1)

Doğancan Arabacı
Doğancan Arabacı

Reputation: 3982

Without build.settings you cannot include related libraries for AdMob. So you should have a build.settings including this code block:

settings =
{
    plugins =
    {
        -- key is the name passed to Lua's 'require()'
        ["CoronaProvider.ads.admob"] =
        {
            -- required
            publisherId = "com.coronalabs",
        },
    },      
}

And, you cannot see the ads, in Corona Simulator. You should use Xcode simulator, or you should test at a device.

Upvotes: 2

Related Questions