AdMob Extension - open source now

Found:
Works with Defold 1.2.163
Is broken with Defold 1.2.164

1.2.164 is not released yet, I can’t fix for that version yet.

I’m pretty sure I’ve got it with the “update button” in the editor :confused:
image
No problem I switch back to 1.2.163 :smiley:

How odd, I don’t have it.

:sweat_smile::sweat_smile::sweat_smile::sweat_smile::sweat_smile:

Yes, that is indeed odd. We haven’t released it yet.

@Mathias_Westerdahl d.defold.com/stable/info.json shows 1.2.164 as the current version?

Yes, missing for me too, but I am on the editor-alpha channel. That looks like it is from the stable channel.

Will the extension be updated to account for CCPA? This is in effect the 1st of January, 2020.

Here are some relevant links for it:
https://support.google.com/admob/answer/9598414
https://developers.google.com/admob/android/ccpa
https://developers.google.com/admob/ios/ccpa

Yes, working on adding extra parameters.

2 Likes

EXTENSION UPDATE

  • Added support for gradle build on Android. That requires Defold version 1.2.165+.
  • Added a new param restricted_data_processing for the admob.load()call. Set it to true to comply with CCPA.
  • Banner on iOS is now positioned inside the safe area (below the notch and above the navbar).

Remove previously required android dependencies from the game.project file.

8 Likes

I get a crash on iOS when initializing the extension. I can’t figure out why because the log file is a bit mysterious:

default	12:37:31.935386+0100	Game	0x1154d1518 - [PID=0] WebProcessCache::updateCapacity: Cache is disabled because process swap on navigation is disabled
default	12:37:31.936342+0100	Game	-[SOAuthorization init]  on <private>
default	12:37:31.936391+0100	Game	-[SOAuthorizationCore init]  on <private>
default	12:37:31.936439+0100	Game	<SOServiceConnection: 0x283777140>: new XPC connection
default	12:37:31.938097+0100	Game	0x1154f00f0 - [PID=0, throttler=0x11549c198] ProcessThrottler::Activity::Activity: Starting background activity / 'WebProcess initialization'
default	12:37:31.946666+0100	Game	nw_path_evaluator_start [84C1E95A-0A66-4C02-B41A-10978E39A598 <NULL> generic, indefinite]
	path: satisfied (Path is satisfied), interface: en0, ipv4, dns
default	12:37:31.955857+0100	Game	0x1070ebe18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::constructor:
default	12:37:31.955971+0100	Game	0x1154d1518 - [PID=0] WebProcessCache::updateCapacity: Cache is disabled by client
default	12:37:31.958252+0100	Game	0x1154ddbd0 - ApplicationStateTracker::ApplicationStateTracker(): m_isInBackground: 0
default	12:37:31.958359+0100	Game	0x106076e00 - WKApplicationStateTrackingView: View with page [0x1070ebe18, pageProxyID: 6] was added to a window, _lastObservedStateWasBackground: 0, isNowBackground: 0
default	12:37:31.959796+0100	Game	0x1070ebe18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::updateActivityState: view visibility state changed 0 -> 1
default	12:37:31.959970+0100	Game	0x1070ebe18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::updateThrottleState: UIProcess is taking a foreground assertion because the view is visible
default	12:37:31.960036+0100	Game	0x1154f0360 - [PID=0, throttler=0x11549c198] ProcessThrottler::Activity::Activity: Starting foreground activity / 'View is visible'
default	12:37:31.960205+0100	Game	0x1070ebe18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::loadRequest:
default	12:37:31.960293+0100	Game	0x1070ebe18 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::loadRequestWithNavigationShared:
default	12:37:31.960381+0100	Game	0x1154c8618 - NavigationState is taking a process network assertion because a page load started
default	12:37:31.960421+0100	Game	0x1154f0370 - [PID=0, throttler=0x11549c198] ProcessThrottler::Activity::Activity: Starting background activity / 'Page Load'
default	12:37:31.961374+0100	Game	DEBUG:SCRIPT: 
{ --[[0x1184c13d0]]
  is_error = false,
  phase = "init",
  name = "admob",
  type = "init"
}
default	12:37:31.961503+0100	Game	DEBUG:SCRIPT: admob.listener()
default	12:37:31.964853+0100	SpringBoard	[application<com.totebo.game>:56456] Now flagged as pending exit for reason: workspace client connection invalidated
default	12:37:31.964903+0100	SpringBoard	[FBInterfaceOrientationServiceServer] Removing client application<com.totebo.game>:56456.
default	12:37:31.965123+0100	SpringBoard	Removed client for observing orientation events: <FBServiceFacilityServerClientHandle: 0x2823f6850; com.apple.frontboardservices.orientation-observer; application<com.totebo.game>:56456: remote>
default	12:37:31.965563+0100	backboardd	Connection removed: IOHIDEventSystemConnection uuid:D8E6AFFB-A5FB-4F40-96CA-5808AD56D365 pid:56456 process:Game type:Passive entitlements:0x0 caller:BackBoardServices: <redacted> + 368 attributes:{
    HighFrequency = 1;
    bundleID = "com.totebo.game";
    pid = 56456;
} state:0x1 events:0 mask:0x0
default	12:37:31.970733+0100	runningboardd	XPC connection invalidated: [application<com.totebo.game>:56456]
default	12:37:31.971602+0100	mediaserverd	AudioSession_SubServer.cpp:107:ClientDied: { "action":"client_died", "session":{"ID":"0x1411e44","PID":56456,"name":"Game"}, "details":null }
default	12:37:31.973479+0100	mediaserverd	-CMSessionMgr- cmsSetIsActive: CMSession: 'sid:0x1411e44, Game(56456), 'prim'' with [AmbientSound/Default] [Mixable] [System Audio] siriEndpointID: (null) going inactive 0 0
default	12:37:31.975639+0100	mediaserverd	-CMSessionMgr- cmsSetIsActive: CMSession: Stopping deactivate timer for client 'sid:0x1411e44, Game(56456), 'prim''
default	12:37:31.976135+0100	mediaserverd	CAReportingClient.mm:470:-[CAReportingClient sendMessage:category:type:reporters:]: message {
    MXSessionVolume = "0.25";
    MXSessionVolumeOperationProcess = "com.totebo.game";
    MXSessionVolumeOperationTime = 591532;
    MXSessionVolumePlayingState = 0;
}: (
    21964462751801
)
default	12:37:31.976818+0100	mediaserverd	-CMSUtilities- CMSUtility_SendSessionStateAndVolumeReportToAudioToolBox: CMSession: Stopping reporter for session : sid:0x1411e44, Game(56456), 'prim', reporter id = 21964462751801
error	12:37:31.977113+0100	runningboardd	RBSStateCapture remove item called for untracked item <RBProcessMonitorObserver: 0x103819df0; <RBProcess: 0x10592e2b0; 56456; identity: application<com.totebo.game>>; configCount: 0>
default	12:37:31.977895+0100	appstored	StoreKitServiceListener: Connection to Game invalidated
default	12:37:31.979928+0100	runningboardd	[application<com.totebo.game>:56456] Death sentinel fired!
default	12:37:32.010006+0100	wifid	[WiFiTrafficFlowMonitor]: com.totebo.game
default	12:37:32.076167+0100	runningboardd	Removing process: [application<com.totebo.game>:56456]
default	12:37:32.077482+0100	runningboardd	[application<com.totebo.game>:56456] Deleting job: UIKitApplication:com.totebo.game[480a][rb-legacy]
default	12:37:32.077528+0100	runningboardd	Removing job: <RBLaunchdJob: 0x10385a860; pid=56456 UIKitApplication:com.totebo.game[480a][rb-legacy]>
default	12:37:32.078001+0100	runningboardd	Removed job with label: UIKitApplication:com.totebo.game[480a][rb-legacy]
default	12:37:32.078955+0100	runningboardd	Removing assertions for terminated process: [application<com.totebo.game>:56456]
default	12:37:32.079092+0100	runningboardd	Removed last relative-start-date-defining assertion for process application<com.totebo.game>
default	12:37:32.079880+0100	runningboardd	Calculated state for application<com.totebo.game>: none (role: None)
default	12:37:32.083220+0100	mediaserverd	-CMSessionMgr- CMSessionMgrHandleApplicationStateChange: CMSession: Client com.totebo.game with pid '56456' is now Terminated. Background entitlement: NO ActiveLongFormVideoSession: NO WhitelistedLongFormVideoApp NO
default	12:37:32.101619+0100	runningboardd	Calculated state for application<com.totebo.game>: none (role: None)
default	12:37:32.102619+0100	SpringBoard	[application<com.totebo.game>:56456]* Process exited: <RBSProcessExitContext; voluntary>.
default	12:37:32.102724+0100	SpringBoard	[application<com.totebo.game>:56456]* Setting process task state to: Not Running
default	12:37:32.102818+0100	SpringBoard	[application<com.totebo.game>:56456]* Setting process visibility to: Unknown
default	12:37:32.102912+0100	SpringBoard	Removing: <FBApplicationProcess: 0x11227cc00; application<com.totebo.game>:56456>
default	12:37:32.103148+0100	SpringBoard	Process exited: <FBApplicationProcess: 0x11227cc00; application<com.totebo.game>:56456> -> <RBSProcessExitContext; voluntary>
default	12:37:32.103662+0100	SpringBoard	Application process state changed for com.totebo.game: (null)
default	12:37:32.113148+0100	SpringBoard	No longer tracking: <FBScene: 0x281bc2100; sceneID: sceneID:com.totebo.game-default; valid: YES>
default	12:37:32.114734+0100	runningboardd	Acquiring assertion targeting 56456 from originator [daemon<com.apple.SpringBoard>:58] with description <RBSAssertionDescriptor; FBSceneSnapshotAction:sceneID:com.totebo.game-default; ID: 29-58-22508; target: 56456> attributes = {
    <RBSRunningReasonAttribute: 0x102c44e90; runningReason: 17>;
    <RBSGPUAccessGrant: 0x102c3dd60>;
    <RBSCPUAccessGrant: 0x102c5b050; role: NonUserInteractive>;
    <RBSJetsamPriorityGrant: 0x102c42f60; priority: Background>;
    <RBSPreventIdleSleepGrant: 0x102c6deb0>;
}
default	12:37:32.116902+0100	locationd	{"msg":"#CLIUA Marking change", "clientKey":"com.totebo.game", "reason":"Process state from RunningBoard", "assertionLevel":4, "coming":0}
default	12:37:32.158250+0100	symptomsd	com.totebo.game: Foreground: false
default	12:37:32.158335+0100	symptomsd	call _saveAndUnloadSelectState on com.totebo.game exiting foreground state

I use the init code from the docs:

local function listener(event)
	print('admob event type', event.type)
	print('admob event phase', event.phase)
	if event.phase == 'init' then -- Admob has been initialized, now it's safe to load a banner.
		--
	end
end

-- Init Admob.
admob.init{
test = true, -- ALWAYS use test ads, only disable when submitting to the stores.
listener = listener
}

Edit: Oh dear. It was a Lua error, which causes a crash because it’s inside the listener method. As usual, I’ll leave this here for shame.

1 Like

It’s unfortunate if the entire app crashes because of an error in a listener. It can probably be improved. Ping @sergey.lerg

I’m back! :cry:

The app now crashes on Android with this error:

2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: JNI CallIntMethodV called with pending exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Collection java.util.Hashtable.values()' on a null object reference
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]   at int extension.admob.Extension.load(long) (Extension.java:202)
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]   at void extension.admob.Lua.lua_call(long, int, int) (Lua.java:-2)
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]   at void extension.admob.Lua.call(long, int, int) (Lua.java:70)
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]   at int extension.admob.Utils$1.invoke(long) (Utils.java:107)
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]   at void extension.admob.Utils.execute_tasks(long) (Utils.java:121)
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]   at void extension.admob.Extension.update(long) (Extension.java:54)
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570] 
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]     in call to CallIntMethodV
2020-05-14 09:17:02.974 15793-15832/com.totebo.game A/otebo.gam: java_vm_ext.cc:570]     from void extension.admob.Lua.lua_call(long, int, int)

This is the file hierarchy:

Could this have something to do with the extension living hard coded in the project, rather as a dependency?

Edit: Lua error again. Shame intensifies! This time the issue was loading interstitial and rewarded ads on the same frame. Works on iOS, crashes on Android.

Okay, Admob on iOS is working fully. On Android the admob extension goes silent after the first call. This is the sequence:

Initialising:

local function listener(event)
	pprint("admob.listener()", event)
end

local params = {}
params.test = true
params.listener = listener
admob.init( params ) -- Loading ads on callback

Init callback:

DEBUG:SCRIPT: admob.listener(),
{ --[[0x78df936d70]]
  type = "init",
  phase = "init",
  name = "admob",
  is_error = false
}

Loading a rewarded ad (after init has been returned):

local params = {}
params.type = "rewarded"
params.id = "ca-app-pub-..."
admob.load( params )

After the admob.load() call nothing is returned from the extension. If I try another admob.load() call the app crashes.

Any idea what could be causing this?

What does the stack trace say?

2020-05-14 13:02:35.918 31357-31398/com.totebo.game A/tebo.gam java_vm_ext.cc:570] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Collection java.util.Hashtable.values()' on a null object reference
2020-05-14 13:02:35.918 31357-31398/com.totebo.game A/tebo.gam java_vm_ext.cc:570]   at int extension.admob.Extension.load(long) (Extension.java:202)
2020-05-14 13:02:35.918 31357-31398/com.totebo.game A/tebo.gam java_vm_ext.cc:570] 
2020-05-14 13:02:35.918 31357-31398/com.totebo.game A/tebo.gam java_vm_ext.cc:570]     in call to CallVoidMethodV

Looks to be the same error I had above?

I found it. The optional parameter “keywords” is not actually optional:
https://docs.spiralcodestudio.com/extension/admob/load/

This code causes the crash above:

local params = {}
params.type = "rewarded"
params.id = rewarded_placement_id
admob.load( params )

This code works:

local params = {}
params.type = "rewarded"
params.id = rewarded_placement_id
params.keywords = {"puzzle","game"}
admob.load( params )
3 Likes

Good find, will fix, thanks!

2 Likes

@sergey.lerg I downloaded the demo project, and built an apk using Defold 1.2.169 on Windows.

The app crashes around 3 seconds after I tap the Initialize button. I am running on a Redmi Go, Android 8.1.0.

I’ve attached the adb output:
adb_output.txt (197.6 KB)

Do you have google play services installed on your device?