Building for Android
Testing your game on your cellphone for the first time is an exhilerating affair full of nail-biting anticipation. The process of getting there for Android devices has been streamlined for you in the Game Closure DevKit.
Building your game to run on a mobile device is done using the Game Closure DevKit
devkit command-line tool. See the Android Setup Guide for instructions on how to get prerequisites, supported mobile devices, and steps on getting started.
Building an .APK
To build your game for debugging, open a console and change the directory to your game’s top-level folder. For example, after cloning the whackthatmole getting started project:
$ cd whackthatmole $ ls README.md manifest.json resources src $ devkit debug native-android --no-compress --debug --clean [build] Building: debug/native-android ...
If you want to build your game for the Google Play store use the command
$ devkit release native-android
When the build completes, you will see a line such as:
[android] saved to /Users/gc/sandbox/whackthatmole/build/release/native-android/whackthatmole.apk
This indicates where the output APK file has been saved. You can then install it to a connected device.
Installing to a Connected Device
Install an application to a device connected via a USB data cable using the Android Debug Bridge (ADB):
$ adb install -r <path-to-apk>
The -r flag means to attempt a reinstall. Note that this will fail if the APK is signed differently (mixing debug and release versions) so you may need to uninstall your game from the phone to reinstall.
If you run into problems, try our Android troubleshooting guide.
Appendix: Build Options
General build options:
-h: Display this help menu
-c: Clean build before compilation
--resources-only: Skip the native build
s: Clear localStorage on device
--install: Install after build
--open: Install and open after build
--enableReleaseLogging: Print logs in release mode (debug mode always prints logs)
Appendix: Example Usage
For a fast debug build:
$ devkit debug native-android $ adb install -r build/debug/native-android/whackthatmole.apk
For a thorough release build:
$ devkit release native-android $ adb install -r build/release/native-android/whackthatmole.apk