AdMob for Android in Godot 3.x!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys welcome back to this godot android series and finally we have reached admob integration so that's what we're gonna do today we're going to implement a few uh ads and then we are going to publish our game to the app store next lesson so if you're interested in that that's what we're doing and let's get right into it as always like subscribe comment down below if you have any issues or any questions or you want to tell me i'm awesome let's get into it okay so the first thing that we are going to do is we're going to set up our application inside admob um this is not a too difficult of a process i'll show you how it's done so first we're going to sign in so make sure all your ad blockers are turned off for admob so you'll come inside here you'll be inside your admob you may need to do some setup stuff like um setting up your information and stuff like that but i've already done that so we're not going to go over that when your account's set up you're going to go into your apps and you see i've already set up solo assign but we're going to add a new one and we're going to go through so we are going to create an android application and is listed on the store so i couldn't get my internal apps uh shown here so uh here i'll show you play.google.com so if you look at our application here inside google play uh you see that there's a package name here and that it's actually on the google play store if i go inside here you see it shows up internally but if you click yes it's listed on the store and you search it by link it doesn't show up so um until it's released um you're not going to be able to show it it's not going to be able to be shown here if it's listed on any other store you'll be able to do it here as well but we'll revisit this section um when we go to release uh probably i think it's gonna be next video or something like that our next lesson in the series so for now we're gonna hit no um and then continue [Music] so platform android app name we're going to say solo slime video because this is not going to be the active one so let's just say test and do we want user metrics i'll just keep yes because why not and we create our application so that's easy enough um we're going to look at this app ads.txt next lesson when we go to release as well what we're going to focus on this video is create ad units so we're going to create two units um and i will show you kind of and i'll show you how to make the third kind but we're not going to implement it because i don't have any uh rewards so there's three kinds of ads that this plug-in supports um we'll go look at the plugin in a minute um but we'll do it here so it supports these banner ads it supports interstitial ads and it supports the rewarded app ads as well so let's implement them this is not going to be difficult so the banner ad is going to be simple this is just going to say um we're going to call it default banner and there's advanced settings uh you can choose what kind of ads you want our banner itself is just going to be um it's going to be you can choose between text whatever automatic refresh we are going to do google optimize but you can customize how often the banner will refresh itself and you can also choose these are beta features but what you can ask google to optimize i think is like your cpm or something like that yeah your ecpm floor usually you'd probably just keep this at all prices and let google fill it for you but if you you're looking to get the highest value adds click high floor but you see here it limits the number of ads that will actually show so with that we create ad unit and you'll see that we get a it'll show our app id and the ad id but we can grab these again in a minute but uh just know that they show up once you create your ads so we'll create another ad unit we'll create the interstitial ad this one is going to be our our main main money maker let's call it main money maker now the interesting thing with the interstitial ad is you don't want to interrupt your users too often so you can actually have it cap it for how many impressions you want to have per a certain amount of time so me personally i i'm not interested in spamming everybody with ads if someone's been playing my game for more than 15 minutes then maybe show them another ad but other than that one ad for 15 minutes seems like a one one interrupting ad per 15 minutes it seems about right for me and again we're gonna keep the rest normal and this one here we're actually going to create a video uh well any type of advertisements again but you can limit it to what you're interested in so we'll create this ad unit and again you get your it gives you your app id again and it gives you your ad id and we'll create we'll create one more uh one more ad unit and we'll call this rewarded and this one here um this is your rewarded ad so you know how sometimes uh you'll get like a free continue or something like that right by watching an ad it'll be like you're dead if you want to continue hit hit this watch an ad so you can do this like here let's let's just say free continue and enter amount we'll say 1 continue advanced settings so we can you can choose whether you want to include interactive ads i personally hate interactive ads but again it could lead to decreased revenue um server side verification so this here um if you're running like an mmo or something like that and it's important for you not to be able for people not to just fraudulently create stuff then it'll be important that you set up a callback girl url that google will call when the video has been watched and what that'll do is it'll make sure that that um they've watched the video before awarding them the currency so this this is better for stuff like um if you're generating gems it's like collect 50 gems if you watched a reward you would watch it you would watch the video the phone would google would then call your callback url with a very specific user id here or custom data then you would catch that on the server side and say okay this user has earned 50 gems added to that user's account there's no accounts on my application so we're not going to do that but if you're interested in possibly seeing how this would work leave a comment down below i'll i'll implement it somehow i'll figure out something to add maybe we'll add skins or something actually we're probably gonna end up adding skins for in-app purchases but we'll see again you can frequency cap um for how often they can do it um this one here i don't care let them continue as much as they want if they want to watch ads and give me money that's fine and google optimize everything again all right we have our three ads here so we can leave this for now uh we're gonna have to come back to this page to get the ids but uh the next step we're going to do is we're going to start adding the stuff to our actual application so this is all you need to do um in admob for now so this is the plugin we're going to be using um it's called uh godot android admob plugin uh by shin nil it's it seems like a good plugin it worked fairly easily so let's go into actually using it so it's fairly simple you're going to go to the tags here and click releases and grab the version you're interested in so each one of these versions will say which version it was compiled with um we're using three three so just click this zip file and download it i've already done it so with everything unzipped or open anyway you have two folders so you have admob plugin here which has a release.ar aar and a go to admob.gdab so just like our google play plugin we go into our project directory here click android plugins and cgdap arr and just copy those into this folder here and that's all you need to do for that there and then your admob lib folder here that has a dd file and icon will go directly into your sort your root folder of your project so you can just copy that into your root folder and that's all you need to do with the files themselves all right so let's open the project and start implementing it so we've returned to our project and i'll explain uh what we want to do and then we'll we'll implement it what we want to accomplish is that one when we first open the application we do not want to show an advertisement simply enough because we don't want to just spam people who just join our application with an ad immediately right what i'm going to do is after losing after you lose five times it will display an ad it will attempt to display an interstitial ad one that takes up basically the whole screen and then if that fails if it fails to get an ad from google which could be one of two cases one google doesn't have an ad to give me which means that it there was no ad fill or the second reason why we would fail is because we had the frequency cap on that type of ad so if we go back here we go to ad units our interstitial our main money maker here you see we have a frequency cap of one per 15 minutes if you ask for an ad before that 15 minutes is up it will fail to give you an advertisement so in the case of failing to get an advertisement what we're going to do is we're going to show a banner at the bottom of our screen and simply enough that will just be so if the interstitial the the big one that's going to be in people's way doesn't show then we're just going to show a little ad that's really unobtrusive at the bottom of the screen just in i call this the accidental click zone so my theory with banner ads is that in general people are only clicking them by accident a lot of developers i should say not most but a lot of developers they seem to put the ads or place the ads um somewhere where you're very likely to click it by accident and that's it's clearly on purpose now i'm gonna be doing showing it when it's on the loose screen so let's show here it's going to look like this let's say you lose and then there's going to be an ad at the bottom pretty much where this square is in theory it will be relatively rare for someone to accidentally click this because the only thing you're going to be doing is up here my thought is that if it's down here you might hit it with your thumb by accident while you're holding your phone but it should be unlikely so it might give me a few pity clicks right so that's what we're going to going to do outside of that um we'll see if we can show rewarded ad just to see what it looks like but i'm not going to keep that in my application just because i have no no rewards and i don't really want to implement a continuous system at least not yet so uh if you look at the documentation and i'm always gonna i'm gonna always refer back to the documentation because um if you get lost or if you need a reference and you don't want to watch the video again this is where you're going to go there's a few steps here first is the first step is moving the files where they belong we already went over that the second one is activating the custom build like we did with google play so if you're uh don't know how to set up your custom build uh check that video out it's previous in this playlist and then we want to enable admob and uh check a couple boxes so let's uh go inside our project and then export and then our android export and you see here under plugins we now google admob so you'll want to click that a couple of other things we want to do is we want to enable i know one of them is internet here and the other one is i think network access or something let's see where it says that access network state so let's go here so you enable internet at the bottom of these options panel and access network state here you want to give them those those two permissions yeah so that's everything we need to do for our export so now we have so again we'll just double check we've got admob enabled we have access network state permission and the internet permission now finally all we need to do is uh add a node to our project uh what you want to do is you know you can right click add child click this add child or you can control a and you want to check find admob add mom.gd and add that as a child to your node 2d now this is what we need so let's go over the options here is real is only you should only ever check it click this check box if you are building for export and upload to google play if you have this on and google catches you generating advertisements for yourself during development they could ban your account so be careful just keep this off until you're ready to publish now banner on top uh the the banner ads you can either choose to have them on top or on the bottom i want them on the bottom so i'll turn that off banner size um i don't know which size i want but i'm going adaptive banner seemed fairly small to me but i'll leave it at that for now now we get to the banner id interstitial id and reward id so those if we go back to our admob account and our ads so you see here we have an ad unit id you can either copy it here or there's this button implementation instructions and you can get it from here so this is going to be our interstitial so we'll put that in interstitial and then we need our our [Music] banner take this let's just make sure i've always grabbed them from here so i prefer that spot grab our banner put inside banner and then rewarded which is here we will grab our rewarded id and reward it and then child directed which um i don't remember what child directed means so let's check here child directed if true sets the ads to children directed if true max add content rate will be ignored oh all right so this me i think this means whether or not you're aiming to children um [Music] it basically caps your rating at g so this max ad rating should always match what you set in google play store so in my store i set uh i set my application as g rated so my ads will be g rated as well so that's everything we need to set up to be able to show advertisements except for one last thing so inside our project folder inside android uh in build we have our android manifest.xml we need to add uh one thing to that so i believe i already have it um open in visual studio code so let's look at that now all right so uh if you remember correctly uh when we added our when we added our app what we did is we added this app id and this google play services here so here um what we need is you can simply copy paste this thing here from me this site uh from the readme and we'll put it right underneath here now the the important part about where to place this and i didn't go very into it in depth in it you want it inside this application tag here and the readme actually suggests doing it at the bottom right before the end this place would probably make it very easy to keep track of where to put it i personally just prefer it up here with all the other metadata i'm just i think a metadata stuff that would be at the top of a file so we added the metadata data that for the ads application id but now we need to put in our own application id so once again we go back to admob and if you go to any of your ads and go into your implementation instruction at the top you have um using this app id and you just grab this app id right here and you paste that into this spot here that's everything you need to do to have ads working in your application just for sanity let's make sure that the plugin builds and that the application still launches because if it doesn't then i did something wrong [Music] so screen recorder screen recorder okay so i've got android on here let's click the button and it's going to compile [Music] there we go it's getting there now it's installing it to the device it's opening and it all logs in properly so we know that the plugin is not crashing my application so theoretically we should be good to implement some stuff actually first we're going to show yeah we're going to show an interstitial ad when after you lose five times so here i've already implemented i believe the logic i'm here so i play times variable every time i lose uh where's lose lose game i add one to play times and if i above five on play times i reset play times to zero and i'm gonna load interstitial special advertisement here so how do we do that the first thing we're gonna need to do is we're gonna need a reference to our admob uh object here so here we're gonna do onready our admob as admob equal anyways so we've got a reference to that object now what do we need to do we need to load the application now i believe um to do that it's fairly simple whenever we get to lose here we are going to say admob dot load interstitial so the showing an advertisement takes is two steps the first step is loading the advertisement where it makes a request for the advertisement loads into memory and then the second step is actually presenting the advertisement so we call make a call to load the advertisement here so that we can find out whether or not it was successful if it was successful we showed the advertisement if it's not successful then we show a banner ad right so um we can do that here by here we have admob our admob file here if you go into your inspector on your node tab you'll see here interstitial close interest interstitial failed to load interstitial loaded so we're going to implement these two interstitial loaded interstitial failed to load so interstitial loaded we will connect it to our node dd and on admob interstitial loaded here and this one will be simple if interstitial is loaded then we want to add mob dot show interstitial and that does exactly what it says it will just show the interstitial advertisement once the interstitial's loaded then we can go back to our admob node and on failed to load we will we want to create a new function so here if it failed to load as i explained if if no advertisement present returned returned from admob show banner advertisement and this is uh we do this here showing the banner advertisement it has the same process as showing the interstitial so we do admob dot load banner and then we implement the node for banner loaded and while connecting on banner loaded so if the banner is success oops i put this in the wrong spot okay here admob uh banner loaded disconnect here connecting from here connect that's better so on banner loaded then we will show the banner admob dot show banner and if it fails to load again fail banner failed to load connect we will say admob uh we don't actually have to do anything here so we'll print no advertisements to show like that so that will have or should have assuming nothing is wrong on any end um should have wired up my advertisements properly so after we lose five times it should load the interstitial and then show the interstitial if it fails to load it will load the banner and if it successfully loads banner it will show the banner so let's give that a shot and see what happens hopefully it works hopefully i don't have to debug this live again this is going well so far okay so we loaded now we need to lose five times so um what i'm going to do uh first thing is i'm going to show you how to run a debugger if it's not showing it's going to be a much more in-depth debugger so you want to go to your c drive go to your users folder to your user folder cd local cd app data cd local cd android cd sdk cd platform tools and then inside here you have adb.exe so you can do adb logcat and then pipe symbol grep g-r-e-p you want to be in your your developer command prompt here uh grip and then uh good down now what this will do is it'll now you have a log it'll print out any logs of anything that you uh run on your device so we'll open that and we'll keep this open and see what happens and it should tell you uh it should say whether or not things load properly whether or not you get an error so you'll see here you see here we got we successfully signed into google play and now let's let's um let's die five times so one two three four and one more time five now it should load a interstitial advertisement add loaded and there we go a video ad place [Music] and that's exactly what we want you notice how it says test that at the top you definitely want to make sure you see that because if you don't see that means you're in the wrong mode and you could get in trouble you close that and you see on resumed and it resumes your application and you actually notice here that at the bottom it also opened a banner because i guess i don't know why i don't know why it loaded the banner but it'll open the banner at the bottom as well but so let's do this again so one two three four and five now you'll see it failed to load we got a three and on and loaded and it showed a banner advertisement now to make that more clear uh what we also want to do at this point is we want to hide the ad so you see here if i'm if i want to play the game here i might click the ad by accident because it's actually in the thumb zone right um which was kind of on purpose but i don't want the ad there while people are playing i don't want them to have to try clicking that tiny stupid little x button on the corner that everybody hates so what we're going to do is we're actually going to hide the advertisement once we start the game again so you're only going to see ads when you're not playing the game when you're playing the game ads are gone so what we're going to do is very simply um in restart game here we're just gonna go admob dot hide banner [Music] and then we can run that [Music] and we can see um everything happen this time so you notice here that the interstitial ads now will not be given to me because there's a 15 minute um throttle on those that's why i was trying to make sure everything was done at the same time so that um we can see it all working without having to make too many caveats so we hit start one two three four and let's open our logcat and five leaderboard failed to load ad loaded ad banner shows now if we restart the the banner goes away let's see no no banner because um it only shows a banner every three four and five and then failed to load an ad and a banner shows up and that's how you show advertisements and integrate admob into your application now one last thing we're going to do really quick is we're going to add a rewarded advertisement just see what those look like and see how to handle them so what we're going to do is in this page we are going to add not this page on the lose menu we are just going to add a button add child node button and this button is going to be let's just delete this then delete node okay uh we'll take this button here and we will duplicate it we will put it in the top left corner we are just going to put a big r on it we're going to make it smaller we're going to make it smaller all right so that's our rewarded at [Music] r stands for rewarded so here we are going to go here we're going to disconnect this and we are going to say uh not achievement 3. let's rename this rewarded [Music] so on rewarded pressed we are going to um player rewarded at so here admob dot load rewarded video and again once you load a thing you need to catch whether it loaded successfully or failed so admob rewarded video loaded open started left application failed to load okay so the bunch of stuff here so rewarded video loaded here so we wanted we want loaded we want uh failed to load and we will take rewarded as well because i want to see these are the important ones um for now so first thing we're going to do if it loaded successfully uh show rewarded video so that's gonna be the main butter um then here we are just going to print rewarded video failed to load and for the admob rewarded [Music] we're not going to do anything with it now but we will see that currency i imagine will come back i think i mix what i'm expecting is this will come back as continues or something and amount should come back as one and these will match or should match um i haven't done this before so [Music] i i'm kind of making assumptions here that we're gonna validate in a second uh it should map what we did here roar amount one continue so this would actually be continue right so here we are going to say print currency let's just say um [Music] this and this modulo current that's not this currency and amount i think that's how i think that's the syntax currency [Music] i think that's the syntax for that all right so let's uh i think i think that's good i think that's all we need so let's give that a shot and see what happens i expect that this should work um quite well so this one we're gonna have access to without our restart time timer um actually we have the r here so let's actually fix that before testing it out for posterity i'm always you should always test stuff kind of in a real scenario not really in a fake i just gonna show the loose screen scenario so solo slime everything shows up we log in we hit start we lose and we have the rewarded video and we show this i forgot to show this and it loads the video ad here so it's just like an interstitial ad but it's a rewarded video and you see here it printed on rewarded currency continue amount one and it printed continue on and that's exactly what we were looking for right so that is how you would do it and then let's say we award them their one continue if they have one continue they can continue if they close the application or whatever too soon then it wouldn't reward the currency so if we do it do this again i don't know if it's going to let us it should i don't see why it wouldn't on reward video ad load open video started and it awarded it as soon as that turns into an x it rewards the currency and that's admob that's how you do it it's not complicated it's not too difficult hope you enjoyed the video if you're interested in more next video we're going to be going through the release process of our whole game because the purpose of this is so that you can take this series and from the start to the end of implementing your game with google play services um using godot releasing game so with that said we're done here enjoy the rest of your day enjoy your weekend and hit like subscribe all that crap see you next time
Info
Channel: Ozzadar
Views: 1,353
Rating: undefined out of 5
Keywords: godot android admob, godot admob, android admob, admob, godot, android, godot android, google play, godot google, godot google play, admob integration, godot monetization, how do i make money in godot, add ads to godot, godot ads, admob integration in godot, android game development, godot game development, godot game engine, howto admob, admob tutorial, godot tutorial, android tutorial, godot tutorial for beginners, godot engine, godot admob integration
Id: conXUJ1sSDE
Channel Id: undefined
Length: 34min 1sec (2041 seconds)
Published: Fri Jul 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.