Whether you’re building an Android application in Unity or programming it from scratch, you need to set up the Android SDK (software development kit) before you can build and run any code on your Android device.
On your PC, go to the Android Developer SDK website. Download and unpack the latest Android SDK.
Follow the instructions in Installing the SDK. You can skip the optional sections relating to Eclipse. In step 4 of Installing the SDK, be sure to add at least one Android platform with API level equal to or higher than 9 (Platform 2.3 or greater), the Platform Tools, and the USB drivers if you’re using Windows.
USB debugging is a useful way to debug while connecting your Android device to the SDK, so get this set up before moving on to the next step.
To enable USB debugging, you first need to enable Developer options. To do this, navigate your phone to the “Build number” portion in your device’s Settings. Finding it can be different depending on the device:
Note: On operating systems older than version 4.2 (Jelly Bean), the Developer options aren’t hidden. Go to Settings > Developer options, then enable USB debugging.
Navigate to Build number using the instructions above. Tap on the build number 7 times. A small pop-up notification appears saying “you are now X steps away from being a developer” with a number that counts down with every additional tap. On the 7th tap, Developer options are unlocked. Go to Settings > Developer options, and check the USB debugging checkbox to enable debug mode when the device is connected to a computer via USB.
This can be tricky, especially under Windows-based systems where drivers tend to be a problem. Your device may come with additional information or specific drivers from the manufacturer.
If you are unsure whether your device is properly installed on your system, please read the Android development troubleshooting page for details.
The first time you build a project for Android (or if Unity later fails to locate the SDK), you will be asked to locate the folder where you installed the Android SDK. Select the root folder of the SDK installation. If you wish to change the location of the Android SDK, in the menu bar go to Unity > Preferences, then click External Tools.