How to get AdMob (official plugin) working on Android-Crosswalk

0

Index

Attached Files

The following files have been attached to this tutorial:

.capx

admob-display-ads.capx

Download now 188.56 KB
.capx

admob-iap-android.capx

Download now 195.61 KB

Stats

18,834 visits, 51,216 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 12 Oct, 2015. Last updated 19 Feb, 2019

Setting an ad in your game.

You will have to juggle between Construct 2 and the AdMob website.

Add AdMob to your Construct 2 Project

First, add the "AdMob Ads" plugin to your project (category "Monetisation"). This is a global plugin that is available and accessible from anywhere in the project.

Still make sure to add it on one of your first/main layouts the user will have to go through before being displayed the advertisement (not required, but best practice in terms of logic and project organisation).

Create your adMob adUnit

On AdMob's website, enter the AdMob Interface and go in the "Monetize" tab.

There you can either look for an existing/already published application or add one manually (Clicking the "Monetise new app" button).

Entering manually a new non-published application allows you to still make a adUnit for this game.

Later on, you will be wanting to link that application once you published it.

To do so, you will go into the "Home" tab of AdMob, scroll the page down until you get some table containing all your registered applications.

You'll see under the icon a blue link "Link you app".

Simply click that link and follow the instruction to find and link your application/game once you have published it (even in Alpha) from the Google Play Developer console.

Then you add a adUnit for it (it's the actual ad itself)

It can either be a banner (a rectangle on the screen that still allows for the game to be seen) or interstitial (a kind of full screen advertisement covering the game for a while until the user closes it by clicking a cross).

Find out more about ad formats

For this example we create a banner, and even customize its display directly from the adUnit interface itself, adjusting it to the color scheme of our current game.

The name for the adUnit is entirely up to you, although you likely want it to be as unique as possible for management reasons later on. To do that, be sure that the name refers your game is some way, and be quite explicit.

For the AdMob plugin and ad display what really counts is the adUnit ID that you get once the adUnit created. This complicated code starting with "ca-app-pub" is the code that will refer specifically to your adUnit.

Set the ad in Construct 2

Report the adUnit ID in Construct 2's AdMob's plugin's properties, likely the "Banner ID (Android)" line in the Android category or the "Interstitial ID (Android)" accordingly to the adUnit you have created on the website.

Use the action "Show Banner/Interstitial Ad" to actually display the ad according to the type of the ad.

You can set its position and shape at that moment in the fields of the action.

The position refers to the position on screen and will only affect ads of type banner.

Some banner will take the whole width of screen no matter what.

Some others will position exactly according to the position you've set up.

In the properties of the AdMob plugin, be sure to set the property Test mode to "yes" as long as you are testing your application.

When you'll be exporting your application for publication later be sure to turn that property to "no" and remember the AdMob terms of service do not allow you to click advertisements of your own games once publicly published

Concluding Notes on AdMob

Be sure to check further on the manual article to see what other conditions and actions you have access to.

You'll likely want to "Preload" some ad and display it once you have had the "On banner/instertital received" condition triggering.

That is up to the logic of your game and you likely want to pause any games execution during an "instertitial" (On interstitial presented) and resume the execution once the "On interstitial dismissed" condition has been encountered.

You only need to create one AdUnit type (one of type "banner" and one of type "interstitial") per game.

You can display different ads at different execution times, but you are only relying on this single AdUnit each time.

For further help, I've attached a very simple capx to this tutorial.

The first screen allows you to select the type of ad (banner or interstitial) as well as its position (for the banner).

You then go to a second screen where the ad is actually displayed.

You can use this demo as a base to go on further with your own experiments and how to implement ads.

Don't forget to create adUnits (one of type banner and one of type interstital) in your own adMob account and add their IDs to the adMob plugin in this demo if you are willing to test it out on your own.

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!