Google Play Services for Unity | In-Depth Guide | 2019 | #1 - Getting Started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
my name is Alexander mastery cough and in this video series I will teach you how to implement Google Play services for unity in 2019 now 2019 brought a few changes to the way Google Play works and mainly the one big change that I will address is that all applications have to be 64-bit or at least support 64-bit alongside 32-bit this is only possible in the newer unity version so I will go over that I will go through the all the stuff that you need to do if you're creating a brand new application or if you just want to integrate some stuff just giving you the settings that you will need to implement everything now bear with me as I will make some mistakes there's a lot of pitfalls to fall into in this tutorial series but I hope that you get something out of it and you're able to implement everything perfectly so if you have any questions if you get stuck please tell me on my discord Channel and you can join my discord in the description use the link there to go on my discord and post post questions there let's begin so the first thing that you want to do is you want to open Android SDK and Android SDK manager to see what packages you have installed so the packages that I have is Android SDK tools Android SDK platform tools Android SDK build tools and scrolling all the way down these ones are absolutely required Android support repository Google Play services and Google repository Google USB Driver I think is useful for when you're testing using a USB cable and you connect your phone to it and you use like logcat and billed directly on it I'll show you how to set the app signing so that you can actually do that at Google Play because it requires a couple of extra steps and of last but not least you have to have Android like the platform itself the SDK platform installed so I have Android 10 with API 29 but the unity Google Play plug-in requires you to have Android 6.0 API 23 I guess that because if it works on this one 6.0 or higher will work but if you want to play it safe go to for Android 6.0 okay so let's close that thing and jump right into unity but before we have to make sure that we have the right unity version install going to the your installs and make sure you have unity 2018 or 2019 because they they're the ones that have 64-bit support if you don't have it click on add and you know whatever unity version that you want I would avoid the alpha beta ones because they're just they're unstable sometimes for some of monetization doesn't work on one of them at least recently and make sure that you have Android build support this is crucial if you don't have this you just won't be able to build your application you could do that post you could do that later but you just might as well start a new installation everything will be simpler and you will have JDK Android SDK and Android NDK pre-installed thanks to unity thank you thank you unity hub so let's go ahead and create a new new project call this GPG demo and click create and wait a little bit okay now once you have unity open let's go ahead and download the unity games games plugin like the Google Play services plugin I'll put the link in the description for this so once you're here on the github page click current build and open up this unity package and then just click download so this is all we're looking for we're looking for the unity package I recommend that you open up this repository and you scroll down and this this has all of this information for you to to help you kind of like guide you through everything yeah it's not fully complete so just I'm gonna go through all the steps here so that you don't have to read everything and go through a lot of like you know trial and error and having to get a bunch of like bugs and stuff like that so there's a lot of stuff that I had to Google it's it's been a lot of work so I'll just try to make it concise and simple for you so once you've downloaded the package let's go and import I guess in the asset folder let's go import custom pack and open up desktop Google Play Services plug-in and let's wait until this is finished let's go and go to build settings build settings and change this to Android you have to switch your platform to Android otherwise it won't work so go ahead and do that now I'll pop up saying Google Play services has installed because it tected that that it's Android it's compiling script ok there we go so now it's switch the unity icons at the Android select build app bundle go open player settings other settings and change the package name here to something memorable something that you will be using to refer to your package so I'm gonna call it a master Koth GPG demo set the scripting back-end to aisle 2 cpp well you'll notice that arm 64 is grayed out so you have to set it to aisle 2 CBP and check mark that arm 64 because otherwise you just won't be able to to build a 64-bit now let's go open the publishing settings and open the key store manager you might just see like some key storage might might look a little bit different here bottom line you still just have to create a key store just create a new key store and I'm gonna do a GPG demo that key store create a password just remember this password you will be using this to sign like digitally sign your app bundle when you pop it when you build it so that you can publish it on play store and the Play Store can verify that it the apk is coming or the bundle is coming from you so that they know that it's it's all legit and not like some nefarious person published it so GPG demo okay validity 50 years I mean I doubt your your game is gonna survive that long but even if it does just in case put it 50 years the maximum I think is a thousand so I just put 50 that's the default click Add key and wait okay I guess you don't have to wait that long so it will just ask you to tell you do you want to set them as your project you do yes and every time you build you have to put in these passwords in here if you do not unity will basically spit back at you saying you have to do it put it in the password so if you see password anywhere there you probably forgot to do it I forget sometimes so just a reminder to keep an eye on these okay well so the next step is to write a small authentication script so what we're gonna do let's close this let's create a small folder called scripts and write a really small authentication script so that we can test it so a GP GS authentication we're going to be using this to just log in to Google Play services a lot of tutorials out there already come pre pre-made or whatever with their own little packages and I'm gonna guide you step by step through everything so that you don't have to like wonder oh how did this guy write this package and whatever so an important step here is to let me open up the web page for just a second so the important step is to include the using Google Play games using Google Play games dot basic API and you're also using unity engine social platforms so these are the ones you'll be using okay now you want to create a static variable called play games platform yeah play games platform so this platform we're gonna make sure that this when we initialize the platform we only initialize it once because if you keep initializing it if you say have a script in two different scenes and you initialize it more than once you will have troubles submitting scores and updating scores because it will it will it will have to like recreate the platform you will be able to submit the score once and then your gonna wonder why is it not working the second time I've had this happen and it was a bug and I really hated and I finally figured it out because it literally says here in the documentation so after we do that so let's do play games actually let's do if platform is null if we don't have the platform we have to create it otherwise just don't do anything you can do other ways you could do this singleton where you don't destroy onload or whatever but we're gonna do it this way play games client configuration config equals new play dot builder dot build oops that build so here when when you do builds later on when we go to cloud saving you're gonna have to do cloud dot cool save enabled what is it enable save games so you're gonna have to do enable save games dog built but for now let's just do dot build because we're just doing a authentication which is really simple they referred back to the Google Play games github for more information they have code base in there I'm just going through the steps to explain what's what what to do so let's do play games platform dot initialize instance config and then we need to do I guess we we don't have to do this but this says it's debug log enabled equals true it's useful I guess you don't have to put it in I just put it in because it's in here and then once you play games platform dot activate this is this is what you call when you log in basically and we're gonna set that because it a platform you can see it returns a play games platform we're gonna set that to the platform and that's only if it's null if it's not null then it just doesn't do anything and this kind of ensures that we have one platform running at a time and that we only do it once it's just a quick thing over here instead of just activating the platform we actually have to log in so let's do that first so social dot active local user not authenticate success this takes a callback we'll do a little to the lambda function I do it if success so be a boolean what's your debug log logged in successfully and then else particle no debug that log fail to log in sadface okay let's put this script in an in a game object any moment now okay there we go gbgs authenticator well dump that in there save and I think we are done with this part but let me just verify oh right we need to actually build built the de bundle so let's go ahead and build builds GPG demo save it and we run the build that's it and we wait and I'll come back and I'll continue with the with the instructions ok so when you're building once you build it you're gonna get this error called Google Play games not configured and it's gonna say warning Google Play games was not configured game services will not work correctly don't worry about that we haven't configured it yet because we need to upload the apk to Google Play first before we do anything so let's close that up let's close up the build settings and now let's do the hard part ok the hard part is gonna be just having to upload a bunch of stuff to to the Google Play Store and set up all the settings so let's open up your Google Play console ok I'll put a link for that in the description as well but if you if you also want you can go into window google play games set up Android setup and it will be this little this little whatever thing okay so you're gonna be led to this screen if you don't if you have you know asking you to sign up then you will have to sign up otherwise you just won't be able to there's a twenty five dollar fee so once you pay that they'll process it and then you'll be able to actually use all the services without that you will not be able to use Google Play services in your game okay let one once that is out of the way let's create a new application call it GPG demo or whatever else let's give it a short description demo for GPG and then here is like google game services demo game so you have to upload graphical assets for this you have to have a 512 by 512 PNG high-res icon I already have a couple of these ready just have them prepared you know maybe I'll have a zip file or something maybe I won't for you upload a couple screenshots these could be literally any pictures you can upload multiple of them you just need to you need to for it to work for the bare minimum to to register and then a feature graphic okay set the application type to games action or whatever else just remember to what it is and enter your email address click do not submitting a privacy policy URL at this time because this is just a test game you don't need a privacy policy but you will need one if you're using analytics if using analytics or anything of that sort you will need to supply privacy policy Google requires you to do so you will not be able to have your game now in the Google Play console you have you see these like little grey checkmarks so they will tell you exactly what you need to do you need your app is missing a required content rating go to your apps content page bla bla bla so let's go first to the app releases and it says you need to upload an apk or Android app bundle for this application let's go to the internal test track manage create a release let google manage and protect your app signing key let's do it give it a read like I'm not going to read it out right now but give it a read and and learn what it does and now let's go to our bababa bababa our builds the thing that we just built the a a B file let's upload that and see you know cross our fingers and pray that it that it uploads you have to make sure every time you build every single time you upload to do this this screen you have to make sure that in the player settings in the Papa in the other settings your bundle version code is different every single time so if I upload then another the next time I have to put it to two if I set it to one and I up and I build it again and I upload it it will tell me you have to have a different one it's not going to take it it's going to reject it now here's what's really cool thing about Google Play is that the app download size is seven point three to eight megabytes that is a really small file size for a basic Android app that we've had in unity Oklahoma let me open it up I guess Google Play services let's do here it is so we'll see that in the builds it's 14 megabytes and here it's only 8 so Google Play automatically takes your app bundle this is what the app bundle does and it just strips away all that crap it doesn't need this is really useful because people just won't want to download your app when it's 300 megabytes unless you're a three billion dollar company so let's save let's review and now we should be a start roll out internal test check the warnings this warning is gonna be some crap about like languages or whatever oh no testers remember that you need to set some testers ok let's let's let's just go down the check mark let's do content rating because you've uploaded an apk let's do a Content rating so let's do an email address let's confirm the email address oops that's not it select your app category reference news are educational in this case that's basically what it is I don't know exactly but let's do no no no we don't it's an empty app we literally do not have any sort of thing does it doesn't share anything it doesn't do anything but do read these I just know them because I've done it before you have to read through all of them and do the questionnaire otherwise Google will be on your ass so let's do save calculate rating I mean this game is for all ages because it's literally nothing so see this green thing item is ready published let's do app content we cannot do that yet because we did not publish the app or something that sort all right we need pricing and distribution so as you set it to free right what do all countries are available no it has no ads no it let's not take care about that content guidelines it absolutely meets them export laws it meets them but please read these you actually need to read these I've read them before so I know that this doesn't it supports them but you need to actually read through all of them and I think now we can do app code yeah so there we go so go to app content and click start as games for everybody man everybody it does not appeal to children you guys children I don't think so if you are good on you for learning this unique if you learn this young you can you can get a really big leap ahead of everyone else okay let's uh what did I do start again let's just go through all of this again fantastic so now you see all these green checkmarks this means we're done but it actually means we're half done so let's go to yes so let's just just to make sure everything is good yep it's all good let's go applications now instead of going to all applications where we see our GPG demo we have to go to game services and now we have to set up a new game for the game service so let's do gbg demo this is an action game I guess okay I have to wait for it okay you don't really need a description here saved games this is important when we have saved games to the cloud Google Google Cloud Google saved games you need to set this to on however because we cannot turn them off after publishing let's just set them to off for now and then we'll come back to it later in the in the other video these are the same icons you don't really have to do any of this so now that we save this we go to linked apps and this is an important step because we need to select in the package name the the other game that we created earlier in the all applications section so we just basically need to link those two applications turn-based multiplayer I will not be covering these multi players anti-piracy I have not used it I think it has something to do with preventing you from downloading the apk from other sources disable that because I think we you need it for testing and click Save and continue now it says item not ready what's up with that we need to authorize your app so here's the thing so in the linked apps you have to click here sorry click game details apologies game details scroll down to the bottom and you see API console project open this link over here and this will take you to the Google API console which is a different console and here go to credentials and I think you will need to create credentials for this let's let's let's pause that for a second let's go back to linked apps and yeah here we go continued authorized your app and click confirm yeah this will create the off a auth client so now that it's ready you've linked your apps go to game details go down to that open the console again and now I think you should see credentials in here there we go there we go off ooofff 2.0 client IDs open this up and this is an extremely crucial part if you want to test your game locally on your device or in an emulator without having to upload it to Google Play Google store every single time you do it like you make a small change you you know adjust some text and you rebuild it if you want to keep testing that on your phone and then when you have a working version you push that on to Google services or a Google store you have to test it locally in order for you to test it locally you have to change this assigning certificate fingerprint and the way you do that is you go back to back to this screen and you click all applications again go back to this and click app signing here you will have app signing certificate and an upload certificate the app signing certificate is the SHA this is what you will be using to to publish your game on the App Store and use Google Play services from the in those applications so people who you downloaded from the App Store will be able to use stuff like you know achievements and leaderboards otherwise if you want to test it locally you have to use the upload certificate so let's go ahead and change that too so one thing you'll notice is that the app signing certificate sha this thing is right now identical to the one that you have right here so they're the same okay instead you want to have this one what what this means right now is that you'll be able to test it if you publish it to the store and you downloaded the apk from the Google Play Store but you want to test this offline you don't want to go and have to do that every single time so let's paste that one in and click Save once that is saved remember if you want to switch back to remote testing when people can actually go and download the app and test it locally I'm sorry test it from the store use it like if people are actually using and playing your game you have to change it back so remember the step it's very very important so once you are done that I believe you are done now it says here item is ready for testing so since item is ready for testing I think we will be able to test this game on our phones so let's do something here by going to build and run and oh no hold on I have to plug in my phone first so you can use an emulator for this I will not cover how to do testing how to do all the connection stuff you need to enable like development development on your development mode on your Android and whatever or use an emulator I use my phone I just plug it into my phone and I do a build and run and let's see we're gonna build it and see how that works on the phone ok so really quick entered interests interjection intersection whatever before you build it you have to make sure that the run device is set to whatever device you're doing and also you have to set set up the Google Play command so over here remember this little console that we've had you have to go into Google Play services and set up a oops into the game services and set up at least one achievement or one leaderboard so let's do a leaderboard and we'll just do high score this has to be just like some some basic thing right number of decimal places yes or just larger is better tamper protection was due on list order and then just save so here's what you have to do you have to see this little thing says get resources you have to click that and copy everything from here you have to copy everything from here and then you have to go back into here and paste it you have to do this every time you add a new achievement or a leaderboard and then click setup you have a web app client ID if you if you're using like an online thing now you might also be stuck over here on resolving resolving android dependencies if if this works for you and it starts moving and it's all good and fantastic but if it gets stuck like it does on mine just close that close that thing and let's go build settings and now we can build and run and can build and run a package and then see if it works so I built it and I ran it on my phone and guess what it's working I'm gonna show this to you guys yeah nice it asks you to login this screen just I was asking if you want to do automatic sign-in yes or whatever yeah let's do that automatic sign in and now it's gonna see right there whoa we did it that's it that's all that is to it if you are having trouble if you're you know if you're stuck on some other aspect of this then please please join my discord join the discord and post in the assistance channel asking like you know what's how do i how do I fix this just provide me with some details on the error just read read the read the rules there and please post messages I will be listening I'll be watching and I will help you out if you have something that you know something that I can fix I understand that this is a really annoying thing to deal with like sometimes it's just like a it's really really difficult to kind of go and Google everything and make sure that everything's aligning its it took me two weeks originally when I was working with this because if something would break and then I would have to reset everything and then that other thing would break and then I'll have to do everything over and over and over and over again until I finally kind of boiled it down to almost a science and you notice that I even had trouble setting it up in this video hopefully you can avoid those pitfalls and if you enjoyed this video if you you know if you found it really helpful if you actually work from the first time give it a thumbs up share it with somebody who's working on Google Play services and subscribe and ring the bell if you want to see more videos like this and more videos related to game development I'll be talking about stuff like just general like how to get started doing game development not necessarily unity there will be other unity tutorials in the future you get to decide this is my first video so if you if your early adopter you're gonna get to decide what I make so thank you so much for watching if you have any troubles remember go on the discord and ask me a question thank you so much bye-bye
Info
Channel: AMastryukov
Views: 42,241
Rating: undefined out of 5
Keywords: Game Development, Indie Games, Programming, Unity, Google Play Services, Google Play, Cloud Save, Tutorial, Guide, 2019, 64-bit Android, Google Play Console, Google Play Services Plugin, Google Play Plugin, Unity2D, Unity3D, Unity Tutorial, Unity Guide, Unity 2019
Id: 0LGs1Xtt_1I
Channel Id: undefined
Length: 29min 25sec (1765 seconds)
Published: Wed Jul 03 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.