This is the first post in the Comprehensive Guide to getting your Unreal Engine game on the Google Play store and adding Google Play Services. This tutorial will discuss how to package a properly signed "shipping" build of your game to upload to Google Play.
Created for Unreal Version 4.19
If you're wondering, the answer is yes. We did already do a write-up on this one. Three years ago, in fact. Turns out I didn't even look at our own blog when I started going through the motions here. Silly me. Once you finish my tutorial here, I recommend going back and reading the original article by Itsmyroad. There are several learn-the-hard-way nuggets of wisdom there that I've yet to encounter.
Packaging your game is the first step for adding Google Play Services, even if your game isn't finished. The process for adding a Google Play leaderboard to your Android game is odd. You have to upload it to the Google Developer Console, fill out a bunch of information, create a leaderboard, get Google to generate information so that you can take this back to UE4, connect it to your leaderboard, and then go back to Google to upload the APK again to test it.
Part 1: Install Nvidia Codeworks
Android apps require a few extra tools in addition to the Unreal Engine editor. Luckily, Epic has taken a lot of the guesswork out of this step for you. Kind of.
Each iteration of the engine comes with the install files for Nvidia Codeworks, which in turn contains the install files for all of the other programs required to package a game. At the time of this writing, the executable for installing Codeworks is located at [Engine Install Directory]:\UE4\Engines\[UE_4.19]\Engine\Extras\AndroidWorks\Win64
NOTE: YOU MUST INSTALL NVIDIA CODEWORKS ON YOUR ROOT DRIVE
Don't have any space on your root drive because you use a smaller, faster SSD to boot your OS and have a larger HDD drive that handles all of your storage? TOO BAD! You'll be handed error after error, even if you identify the SDK install directory in UE4. There's no way around this one. Bite the bullet and free up about 6.5 gigs of space on your root drive for this install.
Most of the proper options are already checked for you in the standard install options. Double-check with the list under the Codeworks for Android 1R6u1 heading here.
Next, bookmark this page so you can come back to it. Once Codeworks is finished installing, it'll be time for a computer restart.
Part 2: Packaging the App
Now that we've got the proper tools installed, we can get the engine ready to package your game for uploading to Google Play. I'm going to move some of these steps out of the order suggested by Epic, but I'm also going to operate under the assumption that you've never packaged your game before.
1. Accept the SDK License.
This one is pretty easy. On the top toolbar, select Edit > Project Settings. Once the Project Settings are open,
Scroll down in the navigation bar on the left to Platforms and select Android SDK. Use the ellipses to set the locations of each of the folders in the SDKConfig. Yours should look exactly like mine in the screenshot because, as stated above, this will not work if you chose another install directory.
Once you have those set, go back to the navigation bar on the left and select Android under Platforms. Click the button for Accept SDK License, read the legal jargon, and then click OK. Leave the Project Settings tab open because you'll need this again in a minute.
2. Initial Development Build Package
If you've packaged your game before, then you can skip this step and move on to Step 3. Go back to the Main Editor tab. At the top toolbar, choose File > Package Project > Android > Android Type. These different versions correspond to different texture formats that the various devices can handle. I chose ETC1 for now because it's supported by all Android devices. Unless you have a good reason, you should probably avoid the "Android (Multi...)" option. It will take up more time and space that the other options and we aren't actually going to be doing anything with this particular APK.
If you want to start your research on exactly which Android format is the best for your needs, then check out Epic's Documentation under the Android Tips and Tricks Android Texture Formats heading.
Once you've chosen your Android build option, choose the save location of your APK. It doesn't matter where you save this. Once you select the folder, Android will start its build. Depending on your device and the size of your game, this will likely take around 10 minutes.
Hopefully this will package your project without any errors. However, even if you do run into an error, you may still be able to skip troubleshooting for now and proceed to Step 3 below if the engine successfully created the "Build" folder inside of your game's project folder. This is entirely speculation on my part.
3. Create the Keystore File
After you've packaged your game once, it's time to sign your APK. There are two different step-by-step guides HERE and HERE, so I'm not going to rehash all of the steps. Basically, you're going to use the Windows Command Prompt to create a Keystore file. Be sure to keep the Keystore name, Keystore Alias name, and the Keystore password somewhere easily accessible because we will need them later in Step 4.
If you're scared of the Command Prompt, you can also create a Keystore by installing Android Studio, importing the APK you created in Step 2 above and choosing the option to sign the APK. That's beyond the scope of this tutorial, but Google explains the process here.
Once you have your Keystore file generated, make sure to put it in the Build > Android folder inside of your project folder. Both linked tutorials above should cover this.
I, admittedly, had more issues generating this Keystore file than I should have. If you are having an exceptionally hard time making yours, leave us a comment and I'll break down that process in detail in another tutorial.
4. UE4 Editor Settings
Now all that's left is for you to fill in some information inside of the UE4 Editor. Let's again go back to the Project Settings menu that you left open all the way back in Step 1 (if you didn't leave it open, Edit > Project Settings in the toolbar).
Under the Project heading in the navigation panel, choose Packaging. Set the Build Configuration to "Shipping," set your Staging Directory as the location where you want your build files to be saved, and check the radio buttons for Full Rebuild and Distribution.
Now find the Platforms heading in the navigation panel and again choose Android. This is where you accepted your SDK license earlier. Click the Open Build Folder button and make sure the Keystore you generated in Step 3 is inside the folder that opens.
Set your Android Package Name. Use the com.[YourCompanyName].[ProjectName] naming convention. Make a note of this name because you will need to enter in the same name on the Google Play Developer website later.
Within the same Platforms > Android heading, scroll down until you find the Distribution Signing subheading. Here you will input the name of the Keystore file in the Build folder. Put the exact name of the file, including the ".keystore" file type. Also fill out the boxes for the Key Alias and Keystore Password. Use the same information from Step 3 where I gave you an italicized reminder to keep this information nearby.
Now go back to the Main Editor window. In the top toolbar, choose File > Package Project > Build Configuration and select "shipping" for the Build Configuration.
Now we will follow the same steps from Step 2 to package the project. In the top toolbar choose File > Package Project > Android and choose your Android build type. Set a save location and start the build. Once this build finishes, you will be ready to upload your APK to the Google Play Developer's Console.
We will cover uploading your APK and the steps it takes to create your leaderboard with Google Play Services in the next tutorial.