Android Ads

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
Hey everyone. Been buzy lately with coding and soon I'll will be releasing my first Android app made with Cerberus-X.
I was wondering, is there any progress on getting the ads freshed up for Android?
 

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
Still not working for you?
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
It might be me doing something wrong, I'll give it a few more days of trying!
 

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
I will check it out myself too, cause by the end of the month I want to release a new version and want to make sure that this part works.
 

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
Needs a rewrite. The current code is not compatible with the latest version 20. I hope I can make it. Will take some time.
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
Thanks for doing this. I'll focus on the all the code around the ads until then in the background.

if I can help in any way I'm happy to do so.
 

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
I have it compiling now without errors. Still need to test this on a device. I will report back when I think it is ready for user testing
 

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
Uploaded the latest changes for the Android Admob. The example should work now again.
 

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
I have uploaded a beta version to itch.io for Windows.
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
Wow this is amazin, I can't wait to try it, sorry for the slow response.

Will try today using the demo id's !

HOW-TO
-----------


UPDATED ( This is what I found out worked for me. Together with all the help I got I finally got it going nicely)
1) Register account (or Login)
2) Create app (or Select app) (It's just a placeholder to keep your ads in order it does not have anything to do with the shops)
3) Create ads (or select ad)
4) Get details about the ad and App

This is where you put them in the example code.
Code:
#If TARGET<>"android" And TARGET<>"ios"
#Error "Admob is only supported on Android and iOS targets"
#End

#ANDROID_LOGCAT_OPTION="-s [Cerberus]:E"

Import mojo
Import brl.admob

' FIND THESE STRINGS BY JUST FOLLOWING THE SCREENSHOTS :
' APP-ID                  : ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy (you see this on screenshot 4, the top ID with an Android icon, it's common for all ads)
' AD-ID (FULLSCREEN-AD) : ca-app-pub-xxxxxxxxxxxxxxxx/aaaaaaaaaa ' (you see this on screenshot 4, the bottom)
' AD-ID (BANNER-AD)      : ca-app-pub-xxxxxxxxxxxxxxxx/bbbbbbbbbb ' (you see this on screenshot 4, the bottom, after done the same for the other ad)

' WRITE YOUR APP ID HERE (don't forget to add an additional ~ because how strings manages special symbols)
   #ADMOB_ANDROID_ADS_APPID = "ca-app-pub-xxxxxxxxxxxxxxxx~~yyyyyyyyyy"

' WRITE YOUR BANNER-AD ID HERE
   #ADMOB_PUBLISHER_ID = "ca-app-pub-xxxxxxxxxxxxxxxx/aaaaaaaaaa"

Class MyApp Extends App

  Field admob:Admob
  Field interstitialAdmob:AdmobInterstitial
  Field layout:=1
  Field state:=1

  Method OnCreate()
    admob=Admob.GetAdmob()
    admob.ShowAdView 1,layout
   
    ' WRITE YOUR INTERSITIAL-AD ID HERE
    interstitialAdmob = AdmobInterstitial.GetAdmobInterstitial("ca-app-pub-xxxxxxxxxxxxxxxx/bbbbbbbbbb")
 
    SetUpdateRate 60
  End

  Method OnUpdate()
 
    If MouseHit( 0 )
      If state = 3
                                        admob.HideAdView
        state+=1
      Else If state = 1
        layout+=1
        If layout=7 layout=1
                                        admob.ShowAdView 1,layout
        state+=1
      Else If state = 2
                                       admob.HideAdView
                                       interstitialAdmob.ShowAdViewInterstitial
        state+=1
      End
    End
   
  End

  Method OnRender()
    Local en:="disabled"
    If state=2 en="enabled"
    Cls
    PushMatrix
      Scale 2,2
      DrawText "Click to toggle ads! ads are currently "+en,DeviceWidth/4,DeviceHeight/4,.5,.5
    PopMatrix
  End

End

Function Main()
  New MyApp
End

1 Register account and login.png




2 Select app.png
3 Select ad.png

4 Get details (App-ID & Banner ID).png
 
Last edited:

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
Btw I compiled the github sourcecode and interstitialAdmob.ShowAd still gives "Identifier 'ShowAd' not found" I forgot what I had to change to get passed it.

Found the mod needed for the example :

changed interstitialAdmob.ShowAd
into
interstitialAdmob.ShowAdViewInterstitial
 
Last edited:

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
I tried the demo now and I first got :

first three one sequentially (320x50 px / 460x60 / 468 test ads at the top
them lastly a ' intertestial" fullscreen when you close it

After that it's black with text and there's no way to get ads again it seems. I hope that is the correct behaviour.
The text is from the start "ads are currently disabled" except in state 2 (you can see it goes to disabled just befoe showing the fullscreen ad) and i think the text never changes while the ads are showing.
 
Last edited:

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
I have same source like github and they work for me in the example. The CX api didn't change besides the config value for appid.

And this is only for Android. I have no way to test and develop for Apple anymore.

Regarding the demo, I have to look.
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
I updated the thread and took away all my uncertainties that I had at the beginning and instead wrote the steps wrote how I got where I am now I still have some testing to be done (for instance I don't know how to activate demo-functionality on my own account so I don't dare just yet to use it) but everything looks very promising!

Regarding platforms it's the same here I just develop for Android, no ios atm. I just read Googles instructions so i have to add that I havn't not tested yet on ios. It just helped me understand what the publisher ID's are.
 
Last edited:

MikeHart

Administrator
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,390
Ok, so your statement that the sources from Github don't build still stand?
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
The example still need some editing.
interstitialAdmob.ShowAd needs to change into
interstitialAdmob.ShowAdViewInterstitial. Then it builds fine

But I'm concerned about the behaviour of the example. The state variable only shows up as "enabled" just before the fullscreen ad.
As well as the fact that you cannot loop around the states after one round of ads, it gets stuck after the fullscreen ad is closed.
 
Last edited:

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
#REM
 
Last edited:

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
705
If I'm right, ADMOB_PUBLISHER_ID in the examplecode is actually supposed to be the banner-ad ID?

I am actually not too deep into this, but I guess the reason for the stange naming is just that all the admob stuff started with banners only and one id, and with time interstitials were added without breaking existing code.
Maybe now it is time to reconsider the naming and also the api of this module. @MikeHart and I already had a short conversation about that.
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
Love it, and thank you both for working on this.
 

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,229
Wow got test ads working with my own account so updated this thread higher up with a HOW-TO guide!

Some breakthrough
I'm still not sure how functional the different states in the example are but the main ad function is absolutely there!
About the state I *think* this might be the missing to make ads show again after the intertestial :

Code:
Method OnResume:Int()
    '
    admob.ShowAdView 1,5
    Return 0
End method
 
Last edited:
Top Bottom