- Joined
- Aug 30, 2017
- Messages
- 113
For my first Android Play Store release (Wormy The Worm Like Snake, please go get it. ) I wanted a banner ad for the title page and an interstitial for after Game Over. So after a bit of trial and error (which is why I'm writing this!) I did the following:
(This assumes that all the corrects SDKs are installed for Android eg Google Play Services)
Created an Admob account at https://apps.admob.com/admob/signup
And on this site I:
added an app under the Apps section
created a banner ad and an interstitial ad and made a note of the Ad Unit IDs
In my code in Cerberus I included the following at the top:
"ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" - this is actually the Ad unit ID of the banner ad, without this no banners wil show
I then added the following under the Class
(Although i think I only used the first 2 fields, they were copied from the docs example)
Under OnCreate I added:
"ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" - this is the Ad unit ID of the interstitial ad
i did call admob.ShowAdView 1,5 once at the beginning of ingame but I'm not sure if it was necessary
I also called the interstitial once at the end of the Game Over section using this code
So that the banner would return I also created an OnResume method otherwise the banner didn't return after the interstitial:
As far as the coding goes, that was it. However nothing was yet displaying in the game and I had a few false starts with the IDs I needed to enter. Changing the interstitial to a test id temporarily was showing that my code was ok. Then the final things I did:
release the game
On the Admob Site added a Payment Method
linked the Play Store version of the game within the admob site. (I think that was under App Settings which allowed the Play Store to be searched and the game located.)
To test I downloaded the app from the Play Store and banners and Interstitials were now working:
Hope this helps, if I've got anything wrong (already!) let me know and I'll update this.
Cheers,
Rob
(This assumes that all the corrects SDKs are installed for Android eg Google Play Services)
Created an Admob account at https://apps.admob.com/admob/signup
And on this site I:
added an app under the Apps section
created a banner ad and an interstitial ad and made a note of the Ad Unit IDs
In my code in Cerberus I included the following at the top:
Code:
#ADMOB_PUBLISHER_ID="ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx"
Import mojo
Import brl.admob
I then added the following under the Class
Code:
Class wormy Extends App
' admob bit
Field admob:Admob
Field interstitialAdmob:AdmobInterstitial
Field layout:=1
Field state:=1
Under OnCreate I added:
Code:
Method OnCreate:Int()
admob=Admob.GetAdmob()
admob.ShowAdView 1,5
interstitialAdmob=AdmobInterstitial.GetAdmobInterstitial("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx")
i did call admob.ShowAdView 1,5 once at the beginning of ingame but I'm not sure if it was necessary
I also called the interstitial once at the end of the Game Over section using this code
Code:
admob.HideAdView
interstitialAdmob.ShowAdViewInterstitial
Code:
Method OnResume:Int()
admob.ShowAdView 1,5
Return 0
End Method
As far as the coding goes, that was it. However nothing was yet displaying in the game and I had a few false starts with the IDs I needed to enter. Changing the interstitial to a test id temporarily was showing that my code was ok. Then the final things I did:
release the game
On the Admob Site added a Payment Method
linked the Play Store version of the game within the admob site. (I think that was under App Settings which allowed the Play Store to be searched and the game located.)
To test I downloaded the app from the Play Store and banners and Interstitials were now working:
Hope this helps, if I've got anything wrong (already!) let me know and I'll update this.
Cheers,
Rob