AdMob Extension - open source now

Hi, first of all, thank you.
I want to test the extension, but I faced the issue. Trying to build the example application from GitHub I got the error:

/admob/src/ios/AdmobUtils.mm
	Line 2: 'GoogleMobileAds/GoogleMobileAds.h' file not found
#import <GoogleMobileAds/GoogleMobileAds.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/admob/src/extension.cpp
	Line 36: enumeration values 'EVENT_ID_ICONIFYAPP' and 'EVENT_ID_DEICONIFYAPP' not handled in switch [-Wswitch]
        switch (event->m_Event) {
                ^

I’m using MacBook Pro M1 and Defold v1.2.181

1 Like

Can you try now?

still the same error

Ah, you were building for the desktop, not iOS. Fixed now.

Yey, thank you, it works right now. Should it display ad when I press load banner?

Yes. First click initialize, then load banner. When running on a device.

Can I debug it on the desktop?

I build the application for android using dmengine.apk by pressing initialize I see the error in the console:

WARNING:ENGINE: Unknown Android input method [KeyEvent], defaulting to key events
ERROR:SCRIPT: /main/main.gui_script:67: attempt to index global 'admob' (a nil value)
stack traceback:
  /main/main.gui_script:67: in function callback
  /main/main.gui_script:169: in function button_click
  /main/main.gui_script:189: in function </main/main.gui_script:186>

No, you can’t use dmengine.apk with any native extensions, you have to rebuild it. Defold only uploads Lua code, not native extensions this way.

1 Like

Updated with a few fixes for iOS and Android.

1 Like

Hello, looks like something has been changed. Currently, I’m unable to build the app using Defold v1.2.180 (tried via editor and bob.jar), the error is:

/admob/src/android/java/extension/admob/AdmobUtils.java
	Line 42: strings in switch are not supported in -source 6
		switch (value) {
		       ^
  (use -source 7 or higher to enable strings in switch)
	Line 42: Note: /tmp/job12458279080880895719/upload/admob/src/android/java/extension/admob/Extension.java uses or overrides a deprecated API.
	Line 42: Note: Recompile with -Xlint:deprecation for details.

/admob/src/android/java/extension/admob/Extension.java
	Line 207: strings in switch are not supported in -source 6
			switch (gender) {
			       ^
  (use -source 7 or higher to enable strings in switch)
warning: [options] bootstrap class path not set in conjunction with -source 6
	warning: [options] source value 6 is obsolete and will be removed in a future release
	warning: [options] target value 1.6 is obsolete and will be removed in a future release
	warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.

Try Defold 1.2.181 with the beta build server.

Yes, it works fine, but currently I cannot create signed app using the editor and should use bob.jar and it fails with the error:

Compilation failed with an internal error.
java.lang.UnsupportedOperationException
        at com.android.tools.r8.h.a.a.h.a(:16)
        at com.android.tools.r8.h.a.a.f.a(:227)
        at com.android.tools.r8.graph.D.a(:41)
        at com.android.tools.r8.dex.ApplicationReader$a.a(:12)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1448)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

Hi, since there no releases for the Admob extension on the Github page, What are the steps needed to use it now?

Thanks in advance

Use the beta bob.jar for now

java -jar ./bob.jar --platform=armv7-android clean build --variant debug --archive bundle --bo bundle_android --build-server=https://build-stage.defold.com/ --defoldsdk=ab1f6e99a969b553e9be11be160dbfcd42357c67
1 Like

Use the master branch.
https://github.com/Lerg/extension-admob/archive/master.zip

Thank you very much, works like a charm.

1 Like

Thanks

1 Like

Hi, I get the “resource cannot be null error” whilst bundling using the master branch. Please can you help me with it?

Perhaps, it depends with https://britzl.github.io/manifestation/ Check parameter jetifier: true in your App Manifest file for Android target (armv7-android and arm64-android). If not setup custom manifest and add it to game.project file.

1 Like

We are now defaulting to AndroidX on the build server so it is no longer needed to have an app manifest.

If you do not wish to use AndroidX and prefer to old Android support lib you can use an app manifest to disable it. I’ve updated the Android X section of the Android manual to reflect this:

3 Likes