AdMob Extension - open source now

Hi. Can you try copying admob directory from the extension project into your game project and checking on iOS or Android?

Yeah I’ve done that (I’m testing on Android). Also tried to just run the demo and get the same problem.

1 Like

That is very strange. Are you using the latest Defold version? And can I ask you to record the video how you setup the project and get the error? Let’s start with desktop, on desktop you should see “admob extension is not supported on this platform” when trying to call admob.init().

Yes, I’ve got the latest version of Defold. I’ve follow the instructions with the extension including the bundling bug workaround, so the admob directory has been copied into my project.

I get the “admob extension is not supported on this platform” when running the game on Windows and the error message on Android as follows in the video:

Then that’s the answer.
If you look at the source, only two platforms are supported: https://github.com/Lerg/extension-admob/tree/master/admob/src

1 Like

Ah, live reload doesn’t work with native extensions. You have to build an APK and install it on the device the regular way.

1 Like

Solved in 1.2.138

3 Likes

Awesome news! Will test myself soon.

1 Like

I cannot get this extension to work. I am using Linux, and downloaded the sample project, opened in 1.2.144, with the same version dmengine.apk on my phone. When I go to build/debug the app, I get "attempt to index global ‘admob’ (a nil value).

Also, when I try to bundle an android application, I get: Failed building Android resources to R.java: … values.xml:88 error: Attribute adUnitId has already been defined.

This was me just downloading the project from github, unzipping it and opening it in Defold, I made no other adjustments.

Building the demo project works on macOS, but on Windows and Linux it seems to be failing.

Live building (when using vanilla dmengine.apk) doesn’t work, because it doesn’t include the extension. Defold can’t bundle extensions over air.

Can you try removing the admob directory from the project and add the dependency in game.project. And bundle for Android this way.

1 Like

I did that, and I get "values.xml:88: Error: Attribute “adUnitId” has already been defined.

1 Like

From the README:

A minor change was required to admob/res/values/values.xml , and that was removing the adSize and adUnitId attributes (due to a build error)

1 Like

Getting errors when building for android. Any ideas? When I remove the dependency it goes away

Failed building Android resources to R.java: Failed building Android resources to R.java: C:\Users\etern\AppData\Local\Temp\tmp15120775400557968023bundle\resources\values\values.xml:39: error: Attribute "imageAspectRatioAdjust" has already been defined

C:\Users\etern\AppData\Local\Temp\tmp15120775400557968023bundle\resources\values\values.xml:48: error: Attribute “imageAspectRatio” has already been defined

C:\Users\etern\AppData\Local\Temp\tmp15120775400557968023bundle\resources\values\values.xml:50: error: Attribute “circleCrop” has already been defined

C:\Users\etern\AppData\Local\Temp\tmp15120775400557968023bundle\resources\values\values.xml:52: error: Attribute “buttonSize” has already been defined

C:\Users\etern\AppData\Local\Temp\tmp15120775400557968023bundle\resources\values\values.xml:60: error: Attribute “colorScheme” has already been defined

C:\Users\etern\AppData\Local\Temp\tmp15120775400557968023bundle\resources\values\values.xml:69: error: Attribute “scopeUris” has already been defined

Updated the extension.
Added option to show non-personalized ads. For EU users a consent request should be made to show personalized ads.
Pass

non_personalized = true

To admob.load() to show non-personalized ads.
https://docs.spiralcodestudio.com/extension/admob/load/#non-personalized-sub-optional-sub

Fixed crash inside admob listener when invoking script instance related functions like go.set_position().

Fixed compilation errors. At the moment building for Android works on macOS, but on Windows extra research is required.

4 Likes

Awesome! Thank you for adding this option @sergey.lerg! :smile:

1 Like

Are there known compatibility issues with Monarch?
If I show the ad from a Monarch pop-up screen, it will show the first frame of the test ad or so and crash. But if I show the ad from the main screen, it will work just fine… Any leads into this?
Thanks

Using the most recent version on github? What platform, what does the crash say?
Should be compatible.

Mmm I think I found why it didn’t work. So all calls to the extension have to be in the same script, correct?
I was loading and showing in a secondary screen, even though I initialized the extension in the main one.

Hm, yes, the script should be the same.