Tutorial: Publish Your Game to Android
I wanted to see what my game would look like when published to the Android platform instead of WebGL, so I decided to take a dive into the unknown and give it a shot. It was extremely confusing to set up, and the instructions provided by Unity did not work. After a ton of trial and error, along with researching forum posts across the web on sites like StackExchange, I was finally able to get my game published as an APK (Android Package File). In an effort to help others avoid the pitfalls I made, I've put together this tutorial to explain how I did it. I am using Unity 2017.4.0f1 Personal (64 Bit) on Windows 7 (64 bit).
First, switch your Unity platform to Android by going to File -> Build Settings. Select the Android platform and click "Switch Platform":
Next, download and install Android Studio. Open it, select "Configure" and choose the "SDK Manager" from the dropdown menu:
Now you need to select the version of Android you are running on your phone and hit "Apply". In my case, I'm using a Samsung Galaxy S8 with Android 8.0 (Oreo):
If you don't know how to find out what version of Android you are running, most phones have it listed in the "About Phone" section of the device.
Next, you need to download the Android SDK Tools (Software Developers Kit) version r25.2.5 for Windows. If you are using MAC or Linux, you can download them here. Unfortunately the most up to date versions of Androids SDK Tools didn't work for me, so I had to keep testing old versions until I found one that worked. Version r25.2.5 ended up working for me. It's from the June 2017 SDK Tools release.
Next, you need to download and install the JDK (Java Developers Kit) from the Java Archives. The specific version that worked for me was jdk-8u131-windows-x64.exe for Windows x64. Again, this is because the latest version of the JDK didn't work for me. I had to revert to this older version instead. You will be prompted to make an Oracle account in order to complete the download. Do it, it's free and takes 1 minute to do.
Next you need to find the "AppData" folder on your Windows PC, which is hidden by default. (don't ask how long this took me to figure out...) To un-hide the AppData folder, go to Control Panel -> Appearance and Personalization -> Show hidden files and folders:
Select "Show hidden files, folders, and drives and hit "Apply":
Now navigate to your C: -> Users -> (Username) -> AppData -> Local -> Android -> Sdk -> tools folder and delete everything inside it.
Then go back to the Android SDK Tools version r25.2.5 zip that you downloaded earlier and unzip it. Copy/paste the contents from inside this folder to your C: -> Users -> (Username) -> AppData -> Local -> Android -> Sdk -> tools folder.
Essentially what we have done is replace the tools folder from the original Android SDK with the tools folder from the new r25.2.5 Android SDK.
Now open Unity and select Edit -> Preferences and choose "External Tools":
This is where you'll tell Unity where your SDK files reside. The SDK path for Android should be:
The only thing you need to replace is the "YourUsername" I've put in bold. Change that to be your computers username.
Then you'll update the path for the JDK as well:
Exit the Unity Preferences screen.
The final step is to download and install the USB drivers for your Android phone. First, plug in your phone to your PC's USB port (doesn't matter which one). Since mine was a Samsung Galaxy S8, I had to download my drivers from their website. Your phone may be different, but a quick Google search will find your phone's USB driver's quickly.
Now you are ready to test your game on your Android phone. In Unity, go to File -> Build and Run.
BOOM! Your game is now an app on your phone that you can play whenever you like!
If you get any errors, then your SDK or JDK versions are incorrectly installed or incompatible with your version of Unity, your PC's OS or your phone's OS and will require trial and error to find versions that work for your setup. This tutorial worked for me and is not guaranteed to work for your devices. Either way, this guide should give you an idea of what steps you need to take to get this to work. Good luck!
Multimedia Designer / Game Developer
The Last AntLion