• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android Insert a BANNER AD with AdMob...

A

ArtCode

Guest
Hello to everyone,
I'm creating a little free videogame for Android, but also I want to add Ads.
I created a Google AdMob account and all necessary.
I created an AD with his ID, now I'm following this Official Guide but it doesn't works.

Here is my code:
To do this I created 2 empty Objects and insert them to the room.

obj_LoadAds
GAME START Event
Code:
GoogleMobileAds_Init(ca-app-pub-7345505760380035/6302105897);
GoogleMobileAds_LoadInterstitial();
obj_BannerAd
GAME START Event
Code:
GoogleMobileAds_AddBannerAt("ca-app-pub-7345505760380035/6302105897", GoogleMobileAds_Banner, 0, 0);
This are only few lines of code but still I have some problems...
The error message is:
Variable obj_LoadAds.banner(100003, -2147483648) not set before reading it.
at gml_Object_obj_LoadAds_StartGameEvent_1 (line 3) - GoogleMobileAds_Init(banner);
The messagge is saying that the Object is NOT set in the room, but he is present....
 

klys

Member
Remember to put ads on TEST MODE or you will be banned from adMob.

The error you are having in this line

GoogleMobileAds_Init(ca-app-pub-7345505760380035/6302105897);

it should be in this way

GoogleMobileAds_Init("ca-app-pub-7345505760380035/6302105897");

that thing is a STRING not a variable inside game maker so must be inside "


also you are loading a intirtistial but you want to show a banner

you should not cast
GoogleMobileAds_LoadInterstitial();
 
A

ArtCode

Guest
Thanks a lot for your answer!!! Its very clear! :)
Another little question, how I put the ad on TEST MODE? I need to set this from the AdMob's website?
 

klys

Member
For set adMob in test mode you first need to execute your game from Game Maker Studio compiling the apk, a Console will pop up and it will say something like "For testing device use ....." you have to copy only the CODE, then in Game Maker Studio set the code with this line

Code:
GoogleMobileAds_UseTestAds(true, "CODE_GOES_HERE");
that is it!

Your wellcome!
 
L

lestat0

Guest
Thanks klys !
Now I see that how can I setting arguments about [GoogleMobileAds_UseTestAds].
 
U

Uberpink

Guest
hi, did your banners show up? im struggling with the same, so just wonder how your code look like... im also using admob

this is my code: its not showing any ads :(

GoogleMobileAds_UseTestAds(true, "ca-app-pub-3940256099942544/1033173712");

app_id = "ca-app-pub-9235698069544896~2943283761";
banner_id = "ca-app-pub-3940256099942544/1033173712" ;


GoogleMobileAds_Init(banner_id,app_id);
 
Top