Here is my error with admob : /main/main.script:3: attempt to index global 'admob' (a nil value)
Here is the line of code that is not working : admob.init('ca-app-pub-000', true)
I have also tried like this admob.init{ app_id = '000', test = true, listener = listener }
I am trying it on android. In the emulator it says admob not supported on this platform. When I run it on my phone, it says that error. The extension says to manually put the admob file. I followed all the instructions. I also get this error with the example.
I used the over wifi deploy to get the error. I also tried to export to apk then launch on phone and it launched correctly but there was no ad and no way to see if there was an error.
When using native extensions, you need to bundle for android, into an .apk.
Put that apk onto your device (e.g using adb)
You can view the logs using either adb logcat or Android Studio.
Wow I did not know that. I will try now. Thanks for taking the time to help me. I love defold. I started 2 weeks ago and feel like a pro with such an intuitive software.
Hi! Sorry for the delay. I tried the example on github of your extension and it gave me that error on the remote launch of defold. I will try to export the example as apk and send it to my phone.
Hello again! I tested the test app on my phone and the test ad worked. Now I am trying to implement it into my game but I am having some trouble. In my init function I have this code :
admob.init{
app_id = 'ca-app-pub-685162264159115~9352519994',
test = true, -- ALWAYS use test ads, only disable when submitting to the stores.
listener = listener
}
Here is the code that makes the banner show up just in the script (not in init, update or anything)
local function listener(event)
if event.phase == 'init' then
admob.load{
type = 'banner',
id = 'ca-app-pub-561651641115/5277419906',
position = 'bottom',
size = 'smart',
position = 'bottom'
}
end
end
When I launch the app, it does not show up. What else do I need to put in?
If you separated those two pieces of code apart, it won’t work since the listener variable is not visible to the admob.init() function.
You can move this part
admob.load{
type = 'banner',
id = 'ca-app-pub-561651641115/5277419906',
position = 'bottom',
size = 'smart',
position = 'bottom'
}
to another script, but you have to make sure, that you have called admob.init() before invoking admob.load() and that init process was successful (init phase of the event).
I moved the function code above the init code in the init function. There is still no ad. I looked at the example and there was no init. All I need is a simple banner ad.
local function listener(event)
if event.phase == 'init' then -- Admob has been initialized, now it's safe to load a banner.
admob.load{
type = 'banner',
id = 'ca-app-pub-5899342264159115/5277419906',
position = 'bottom',
size = 'smart',
position = 'bottom'
}
end
end
admob.init{
app_id = 'ca-app-pub-5899342264159115~9352519994',
test = true, -- ALWAYS use test ads, only disable when submitting to the stores.
listener = listener
}
function init(self)
collectionfactory.create("#collectionfactory")
--admob.init('ca-app-pub-5899342264159115~9352519994', true)
end
function final(self)
sound.stop()
end
Here is my code that is in main.scipt. Here is my collection structure.