Admob extension callbacks

how do i detect if user presses on ad so i can hide/unload it
for me seems like there is no way from its current API to do so since callback function is only called upon load() or when user presses (x) or back while interstitial is showing

i am aware that this wast just an example extension but for someone who is unable to read or extend it this is his only hope :smiley:
pls dont point me to Enhance, i tried it and my 4mb game grew to 20mb :frowning:

1 Like

Perhaps it’s an option to use the AdMob extension from the community?

3 Likes

i was also looking into it and couldn’t get it working on android
some kind of ‘resource’ error appears even if i do +workaround+ steps as described in readme doc
both in editor 1 and 2
in values.xml file i get error adSize , adUnitId are already defined

Hmm, I don’t know exactly what those problems mean. Perhaps @sergey.lerg knows more?

hey, i got it working i just renamed these lines from values.xml file and it built successfully

attr name=“adSize” format=“string”/>
to attr name=“adSize1” format=“string”/

attr name=“adUnitId” format=“string”/
to attr name=“adUnitId1” format=“string”/

although i am not sure if this is healthy even if the demo seems like working perfectly i have no idea why those two lines caused error

1 Like

Hi, make sure you are using the game.appmanifest file. It tells Defold to exclude it’s own google play services lib.
That file has to be selected in game.project settings under “native_extension” section.

i did everything still i cant build for android until i rename those two lines
can you please check if this is caused by multiple definition of variable in
java/com/google/android/gmscore/integ/client/admob/res/values/ads_attrs.xml
and
\lerg_admob_test\admob\res\android\res\values\values.xml
at line 84 and 88

That’s Defold’s internal file, it should be excluded by that game.appmanifest file.
Please double check it, copy the file into the root of your project, make sure it says

platforms:
    armv7-android:
        context:
            excludeJars: ["(.*)/google-play-services.jar", "(.*)/android-support-v4.jar"]

And is correctly picked up in game.project file.

it was like that from the beginning

Hmmmmm. Any other extensions?

i have a project with defolds admob extension and it builds with no problems in both editor 1 and 2
its using the same game.appmanifest content

So if you download the project from github https://github.com/Lerg/extension-admob
and open it in Defold as is, it makes that error?

yes sir
has anyone else complained about this ?

Nope, you are the first. What OS?

Windows 7
i mean, it is obvious that the file is not excluded for some reason
is it safe to go with my renaming solution ?

It is strange. But do try using the extension with renaming (you can delete them instead), if Defolds google play services jar doesn’t get excluded you will get runtime errors on using the sample app. If no errors - you are good to go.

everything works banner can show , rewarded video etc.
except one thing
if i press ’ init’, ‘load interstitial’, ‘show interstitial’ , and close ad by (x) or back button , then if i press again ‘load interstitial’ , app crashes instantly
but if i press ‘init’ every time before ‘load interstitial’ button it works as expected

I’m getting the same error too on the same lines in values.xml even the fact that i followed every step and included the game.appmanifest

Windows 7 as well?

I can confirm. Building doesn’t work on Windows, but works on macOS.

1 Like