Android Build Instructions - UO-DFM/SimCityOttawa-Documentation GitHub Wiki
Android Build Instructions
Prepare your device
- Enable developer mode on your device
- Enable USB Debugging
- Connect your device to your computer with a cable capable of data transfer
- Set USB for file transfer
- If prompted trust the connected computer
Unity Setup
- File > Build Settings
Ensure the platform is set to android, then click switch platform in the bottom right if necessary
Next to Run Device ensure your device appears in the drop-down menu, otherwise, refresh
Key Store Signing
If building for production/publication, ensure you are building using the registered key store. The key store file along with the password should be provided to you by one of the developers on the team. It is important that this key is not committed to the source code and is kept private.
Edit > Project Settings > Player Settings > Publishing Settings
If building for test purposes, the debug key will work just fine, simply uncheck Custom Keystore and the game with be signed using the debug key store located at.
C:\Users\%User%\.android\debug.keystore
Overwrite this debug.keystore with one that has been registered as an oAuth Client in the google cloud console
If you'd like to generate your own debug key follow the instructions here
Install Dependencies
In order to build the project correctly, there are a number of dependencies that must be installed on your development machine.
To start, head over to your Unity Hub installation and ensure you have installed Android Build Support both Open JDK and Android SDK & NDK Tools
Installs > selected version > gear icon > Add Modules
In order for Unity to leverage these tools we must register their locations as environment variables on your system
Set the following Environment Variables
ANDROID_HOME
C:\Program Files\Unity\Hub\Editor\2021.3.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK
JAVA_HOME
C:\Program Files\Unity\Hub\Editor\2021.3.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
Google play plugin Dependencies
To install dependencies for the google play games plugin for unity we'll use the sdkmanager cli tool published by android studio.
There is a graphical interface version of this tool packaged with android studio, however, the names of specific dependencies may differ.
The sdkmanager cli is installed with android build support in your unity editor installation Simply add the following to the Path to access the cli
C:\Program Files\Unity\Hub\Editor\2021.3.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools
C:\Program Files\Unity\Hub\Editor\2021.3.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin
C:\Program Files\Unity\Hub\Editor\2021.3.11f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools
Once the cli has been installed and added to your PATH, open up power shell with administrator priviledges and run sdkmanager --list
to see the packages currently installed on your system.
Note: if you get the 'Could not determine SDK root' error, see the following stack overflow link
The plugins readme currently lists the following required dependencies
Google Play Services (extras;google;google_play_services)
Android Support Library (now packaged with android X)
Local Maven repository for Support Libraries (Also known as Android Support Repository) (extras;android;m2repository)
Google Repository (extras;google;m2repository)
Android 6.0 (API 23) (this does not affect the min SDK version) (platforms;android-23).
To install any missing packages, simply use the command below replacing PATH with the path shown in the sdkmanager next to the desired package.
sdkmanager --install "PATH"