Completely lost trying to implement AdMob

Monkey Targets Forums/Android/Completely lost trying to implement AdMob

Arabia(Posted 2013) [#1]
Been searching away, found some stuff and then another post that said all I need is to use brl.admob. So I search the docs, get the example, cut & paste this:

#If TARGET<>"android" And TARGET<>"ios"
#Error "Admob is only supported on Android and iOS targets"
#End

#ADMOB_PUBLISHER_ID="abcdabcdabcdabc"                           'from your admob account
#ADMOB_ANDROID_TEST_DEVICE1="TEST_EMULATOR"
#ADMOB_ANDROID_TEST_DEVICE2="ABCDABCDABCDABCDABCDABCDABCDABCD"  'your device's admob ID for test mode

Import mojo
Import brl.admob

Class MyApp Extends App

    Field admob:Admob
    Field layout:=1
    Field enabled:=True
    
    Method OnCreate()
        admob=Admob.GetAdmob()
        admob.ShowAdView 1,layout
        SetUpdateRate 60
    End
    
    Method OnUpdate()
        If MouseHit( 0 )
            If enabled
                admob.HideAdView
                enabled=False
            Else
                layout+=1
                If layout=7 layout=1
                admob.ShowAdView 1,layout
                enabled=True
            Endif
        End
    End
    
    Method OnRender()
        Cls
        DrawText "Click to toggle ads!",DeviceWidth/2,DeviceHeight/2,.5,.5
    End
    
End

Function Main()
    New MyApp
End


I've changed the:
#ADMOB_PUBLISHER_ID="abcdabcdabcdabc"

to
#ADMOB_PUBLISHER_ID="pub-0000000000000000" ' (not all 0's, but my pub ID from Ad_Mob)



Should I be changing these lines? And if so, where do I find them?
#ADMOB_ANDROID_TEST_DEVICE1="TEST_EMULATOR"
#ADMOB_ANDROID_TEST_DEVICE2="ABCDABCDABCDABCDABCDABCDABCDABCD"  'your device's admob ID for test mode


I've also made a new Ad Unit ID in AdMob (guessing you need one of these for every app?) and it's a string similar to this : ca-app-pub-0000646468501551/0000000000 - where exactly should I be copying/pasting this to?

The code above does compile (with my pub ID in) but when I run in on my Android device all I see is "Click to toggle ads!" and no number of taps on the screen will show me an ad.

Any ideas? Or is there a more complete instructional thread on here that I've missed?


Xaron(Posted 2013) [#2]
You can ignore the test device things. To me it looks fine.

My app ids are much shorter and usually look like

a15************

But I see Admob seems to changed it lately for new apps. I'll take a deeper look into it!
It should run on your device, not in the emulator. Can you post the log output here?

Another idea: Do you use the correct manifest settings? You need network permissions at least.

Last but not least, I'll do another tutorial for this.


Arabia(Posted 2013) [#3]
When I go to install my App I get :

Allow this application to:
* Storage - Mod or delete contents of your USB storage
* Network Communication - Full network access

So I'm guessing that is all in order?

I should note that this is not a live/published app, it is exactly what is above just to test if it's working

I did notice when I was mucking around on the AdMob website getting my App ID (Do I need to put this in the code somewhere? I haven't!) that it asked for an App Name - I just used the name of the App I was working on, but as of yet I haven't bothered renaming stuff - so my App, and this test of AdMob is simply called "Monkey Game" - does this make a difference?

Appreciate the help Xaron. I'll keep messing around in the meantime and I'll post back if I solve my problem, I'm sure it's something simple.


Paul - Taiphoz(Posted 2013) [#4]
http://www.monkeycoder.co.nz/Community/posts.php?topic=5695&post=64319

Does that help ? You might be using the wrong id.


Arabia(Posted 2013) [#5]

http://www.monkeycoder.co.nz/Community/posts.php?topic=5695&post=64319

Does that help ? You might be using the wrong id.



So I'm using my publisher ID when I should be using the App Ad Unit ID ? Can't give it a go at this very second, but I will tomorrow.


Paul - Taiphoz(Posted 2013) [#6]
That's what I had to do at least for bit invaders when I was looking at ad mob. Hope it helps.


Arabia(Posted 2013) [#7]
That could be the problem, will give it a shot tomorrow and let you know. Thanks Paul


Gerry Quinn(Posted 2013) [#8]
You don't need the test stuff at all. Even without it you will see test ads on your emulator. (For Android coding, Admob is uniquely hassle-free!)

One thing you need to check is the logical pixel density on the device. The admob ads are 320x50 but that is multiplied by the logical density which can be between 0.75 and 2.0. The following java code will do it (I stuck it in my copy of diddy.externfunctions as I do with odd bits of code, but maybe we should make a module containing systems-specific bits and scraps of code like this):