Project 0: Spinning Cube

Part 3a: Building and Deploying to Android

Setting the Settings

Now that we know the project works in the editor, let’s go ahead and set it up to be built. First we have to add our scene to the build. Navigate to File -> Build Settings and in the new window that pops up, click on the Add Open Scenes button. Next, switch the target platform to Android. Finally, we have to change a few Player Settings. Note that most Player Settings are platform-specific (i.e. you have a different set of player settings for Android, iOS, etc.).

GIF showing how to go open build and player settings

Identification Settings

The Product Name is the name of the app that you will see when it is installed to your phone. Go ahead and set this to LastName_FirstName_SpinningCube.

Product name setting

The Package Name is your app’s unique identifier on your phone and the Play Store. Set this to com.LastName.FirstName.SpinningCube.

Package name setting

While you should always make sure to modify these settings appropriately, it is especially important to do so in the context of the projects for this class as it makes it much easier for us to grade. Consider the following two scenarios:

Scripting Backend

On Android, Unity gives you the option to use either the Mono or the IL2CPP scripting backend. However, on iOS there is only one scripting backend option: IL2CPP. As a result, we will be using the IL2CPP option in this class.

IL2CPP (Intermediate Language To C++) is a scripting backend that was developed by Unity to increase the performance, security, and platform compatibility of Unity projects. Essentially, when you start a build, it takes the your project and the C# code that you write and converts it into a native C++ project. This code is then compiled into the native executable for the platform, like an .apk file for Android or an .exe file for Windows, or used to generate a native C++ solution for compilation by a specific proprietary tool, like an XCode project for iOS or a Visual Studio project for HoloLens.

If you’re interested in learning more about how Il2CPP works, check out these optional resources:

Go ahead and change the scripting backend option to IL2CPP.

Scripting backend setting

Connecting Your Phone

You will need to have Developer Options and USB debugging enabled on your Android phone in order to install apps from your computer. Instructions on how to do this can be found on the Android Developers site. NOTE: Instructions may vary slightly depending on your phone model and Android OS version.

Once you have done this, connect your phone to your computer with your cable. You should see a pop up on your phone that asks whether you want to allow USB debugging along with your computer’s RSA key fingerprint. Go ahead and click OK.

Building and Deploying the Project

Return to your Build Settings window in Unity and click on the Build And Run button. Create a “Builds” folder in the root of yoru project, create another folder called “Android” for your Android builds, and finally save your apk in there as LastName_FirstName_SpinningCube.apk. It is good practice to store your builds in a “Build” or “Builds” folder, as anything in those folders are ignored by Git with the default Unity .gitignore file (this will be explained further in the final section).

NOTE: If you don’t have an Android phone, you can still build the apk without deploying to an actual device by clicking the Build button instead of the Build And Run button.

GIF showing how to build and deploy project

Once the project has finished building, it will automatically install and launch on your phone.

GIF showing gameplay of built app on phone

Previous Section| Go Home | Next Section