This step by step guide will help you prepare your Unity installation, projects and android device for developing Unity Android Games! Looking for more Unity tips? Check out our other Unity how to guides here!
What you’ll need to get started
- Android Device running Android 4.1 or higher (Unity recently removed support for old versions of android)
- Micro USB cable or other data cable compatible with your device (must have data capabilities!)
Steps to setup your Unity Android Build Environment
- Download the Android SDK
The easiest way to install the android SDK is to simply download Android Studio, it’s a useful Java IDE and the installer sets up the android SDK and other environment variables for you!(If you’re an advanced user and just want the command line tools then you can download it separately at the bottom of the page and use the sdkmanager to install packages separately.)Make sure to keep note of where the android SDK is located as you’ll need it later!
- Download the Java Development Kit (JDK)
Download the latest version of the JDK from the Oracle website here!
- Download the Unity Download Assistant
If you’re a new Unity developer you can started with the free personal edition of Unity here! Otherwise if you’re either not eligible for Unity Personal or own a Unity license you can choose which edition of Unity to download from here!
- Install Unity (With android build support)
During the Unity installation you’ll be asked which features you want included with your Unity installation, make sure Android Build Support is checked!
- Launch Unity and either create a new project or open an existing project
If you’re planning on converting an existing project into an android project make sure you make a backup of the project beforehand!
- In Unity open Edit > Preferences… and select External Tools from the sidebar
- Set the path for the Android SDK and JDK
The SDK path was set during the Android Studio installation, if you can’t remember where you installed it try look in %localappdata% or just reinstall android studio to find the path where you installed the SDK to.
The JDK will most likely be installed into Program Files/Java/jdk<VERSION_HERE> but again you can repeat the JDK installation again if you can’t find it.
- Switch your Unity project to an Android Project
If using an existing project, backup the project now! Most of the project files will be re-imported which can take a VERY long time in large projects!
From File > Build Settings… select the Android platform. Then in the bottom left corner of the build settings click the Switch Platform button.(If you don’t have the android platform shown in the build settings then you didn’t tick the Android Build Support checkbox during installation!)
- Set your Player Settings
Before you can build you’ll need to set a package name, company name and product name. You can also create or use a keystore now too but for testing purposes an unsigned keystore will be fine.
- Build the project
You can build from either the build settings (File > Build Settings…) or directly from File > Build & Run. From the build settings you the following options:
– Texture Compression (Force the texture compression method)
– Build System (Change the build system)
– Export Project (Export a java project to work with in android studio)
– Development Build (Build with debugging enabled so the profiler or frame debugger can be used)
– Autoconnect Profiler (Automatically connect to the profiler when the app is launched)
– Script Debugging (Logcat messages have more detailed information)
Automatically Build and Launch on Android Device
The Build and Run options in Unity will automatically build the APK to a device connected via USB and launch the app when completed.
However first you need to ensure developer mode is enabled on your android device!
How to enable Android Developer Mode
- On your android device open Settings
- Scroll down and select About Device
- Select Software Info
- Find Build Number and repeatedly tap it
After tapping Build Number a few times you’ll see a toast message appear telling you that developer mode has been enabled.
With developer mode enabled, when you try to build and run with your android device connected you will be prompted to accept the USB connection on the android device (there’s a tickbox to remember your computer in future too) select yes and when Unity finishes building your app should automatically launch!
Now that you’ve successfully setup your environment and can build Unity android games, you can now continue development. One important aspect of android development is optimizing your game for the wide range of android devices out there!
Reduce filesize & optimize mobile GPU performance!
The size of your app is very important with mobile games so you might want to check out our guide on Unity texture compression, it explains the different types of compressions as well as tips on reducing filesize and optimizing mobile GPU performance to increase the speed of your app!
Improve performance with static and dynamic batching & learn how to use the frame debugger!
Reducing the number of rendered batches is very important for mobile optimization! Check out our Unity mobile batching guide to learn how you can heavily increase the performance of your android games!