Unity Android Builds
It’s time to do a Unity Android build. Once you complete this tutorial, you’ll be ready to build any of your projects to Android.
Grab your phone! (or tablet)
It’s time to put your game onto a phone (or tablet) so you can start showing it off to friends (or strangers if you don’t have friends).
Building your game out to an android device is actually pretty easy to do, once you have the initial setup out of the way.
Enabling Developer Options
The first thing you need to do is enable the android Developer Options
This is found in the settings of your android device, but as of android 4.2 it’s hidden by default.
To make the developer options available, go to “About device” in your android settings.
Find the “Build number“, tap on it 7 times.
If you tapped correctly…. developer mode should now be available.
Go back to Settings and look for “Developer options” (for me, it’s right above About device).
Picking our options
Enable the Developer options.
Check USB debugging
Optional: Check Stay awake – You don’t have to do this, but if your phone locks it will stop your builds.
Plug it in
We’re done with phone setup, now it’s time to deal with the Unity setup.
Go ahead and plug in your phone or tablet.
Google USB Drivers
If you’re on windows, you probably need to install Googles USB drivers. You may already have them, in which case you can skip ahead.
But if you end up with your device not being detected, make sure to follow the steps in this section.
First, download the USB driver from google here
http://developer.android.com/sdk/win-usb.html
You should get a file that looks like this
Right click on it and select “Extract All”
Open the folder that’s created and find android_winusb.inf
Right click on it and select “Install”
If you’re presented with this security warning, click “Open”
You may be greeted with a User Account Control dialog after that, if so, just click “Yes”
You should see a message saying the installation was completed successfully.
Let’s try a build
Go to your Unity editor and select File->Build Settings
Select Android from the list of platforms and click “Switch Platform”
Now, make sure you have a scene selected in the Scenes In Build area.
If you don’t, you need to add one now.
To add a scene you can open it, then click “Add Open Scenes”
Leave the options at their default values and click “Build and Run“
Create a folder to save the output to, then name your file.
I recommend you create a separate folder for each build platform (Android, WebGL, Standalone, etc)
Do not make it a sub-folder of your Unity project, a build is not part of your project and belongs in a separate place.
Below, you can see I have a folder at c:\builds\SwappyFish\Android and name my output file SwappyFish.apk
Click Save
An Error??
There are a few possibilities for what happens now.
You may have received an error saying no suitable android device was found.
If so, we need to do a bit more setup, if not, skip past this section.
Let’s Fix it
The Easy Way
When you installed Unity, there were options for different build platforms.
If you didn’t select “Android Build Support“, you’re probably missing the required android files.
You have 2 options here, you can re-install Unity with the Android Build Support checked (in-fact, I’d select all of the platforms there to make it easier next time you try another target).
This could be a good opportunity to update to the latest Unity version as well. If you want the easy way, or an update sounds good, go for that option.
The Alternative
This is a bit more involved than the easy way, but if you really don’t want to re-run the installer, this should fix the error for you.
One of the requirements for an Android build is the Java SDK.
If you haven’t already installed it (and didn’t select android build support so Unity would install it for you), you’ll need to download and install it now.
The current link to the Java SDK is here
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
If that stops working, just search for Java SDK on google and pick the one that looks like what’s below
The Java SDK page is not the most friendly to navigate, so just look for these 2 highlighted areas
Accept the License Agreement
Click on the download link for Windows x64
If you have a 32bit version of windows, download the Windows x86 version instead.
When your download completes, open it and you’ll be presented with the Java SDK Installer
Click Next
Keep the default settings and click Next
Now you’ll get another popup, just click Next again
While the installer will allow you to change the destination folder, I recommend against it.
The SDK should be done installing, click Close.
Build Again
Another Error? (bundle identifier)
If you got past the first part, you were probably presented with this error message.
This is telling you that you need to set the Bundle Identifier.
To set your bundle identifier, open the Player Settings under Edit->Project Settings->Player
When you click this, you’ll see PlayerSettings in the Inspector tab
If the Android option isn’t already selected, choose it by clicking on the icon that now
Your settings should look like this now, though your Product Name may be different.
Set a Company and Product name of your choice.
Expand the “Other Settings” area
You’ll see the area “Bundle Identifier” here.
Set your Bundle Identifier to something that matches the pattern. It must start with com, then have your company name, and product name.
These’s don’t need to match exactly with your product and company, but should if possible. Special characters are not allowed here.
My setting for this project is com.jasonweimann.SwappyFish
Once you’ve set your Bundle Identifier, save your project.
Build Again
This time, your build should actually work!
Reminder: Your phone/tablet must be UNLOCKED and plugged in for a build to deploy to it.
Well Done
If you followed the steps above, you should now have a working android build that you can show off.
Put it on a few devices and show everyone what you’ve done!