Android
Technical information
Flax is compiled for Linux platform using Android NDK and build with Android SDK. Supported are system version Android 7 or newer (platform API level 24). Flax uses Vulkan for rendering graphics on Android (min. Vulkan 1.0).
Android Setup
Follow these steps to setup your development PC for building game for Android platform. In case of problems, please follow official documentation of Android platform.
- Install Open JDK (https://jdk.java.net/15 and set
JAVA_HOME
to jdk root folder) - Download and install Android Studio (https://developer.android.com/studio)
- Open Android Studio and complete the setup (install it to the default location or custom one and set
ANDROID_SDK
to SDK root folder) - Install NDK (via Android SDK side-by-side or manually via https://developer.android.com/ndk/downloads/index.html and set
ANDROID_NDK
to install location) - (when using Flax from Launcher) Install Android Platform Tools for Editor installation via Flax Launcher
Build options
See Game Cooker window.
Property | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
Output | The builded game output folder (relative to the project). | ||||||||
Show Output | If checked, after building the output folder will be shown in an Explorer. | ||||||||
Configuration Mode | Game building mode. Possible options:
|
Platform settings
See Android Platform Settings asset.
Property | Description |
---|---|
Package Name | The application package name (eg. com.company.product ). Custom tokens: ${PROJECT_NAME} , ${COMPANY_NAME} . |
Permissions | The application permissions list (eg. android.media.action.IMAGE_CAPTURE ). Added to the generated manifest file. |
Override Icon | Custom icon texture to use for the application (overrides the default one). |
C++ Debugging
- Install
C++ Android development tools
via Visual Studio Installer - Build game for android to
.apk
and install it on the device - Regenerate scripts projects files
- Set startup project to one named
Android
- Edit that project properties:
Debugging -> Package To Launch
set your apk path inPackage to Launch
and setAdditional Symbol Search Paths
to game cooker output location folder withlibFlaxGame.so
file for the target arch ARM64 (<output>/app/jniLibs/arm64-v8a
) - Run the Android project with a debugger on an device
Optionally you can install apk manually and attach to it with
- Use
Debug -> Attach to Android Process
- Once debugger is attached you can insert breakpoints and debug the game code
Android adb logs collecting
Debug and Devlopment builds are using low-level Android logger to output engine and game logs directly to the adb
.
Use .\adb.exe -d logcat Flax:I *:S
to listen for game logs on device.
Vulkan debugging
- Build Debug build
- Copy
libVkLayer_khronos_validation.so
(optionally other validation libs) fromNDK/sources/third_party/vulkan/src/build-android/jniLibs/arm64-v8a
to output Gradle project libs folder (<output>/app/jniLibs/arm64-v8a
) - Monitor adb output log with Vulkan Validation layer logs
- Note that game performance will be lower (esp. CPU) due to additional validation of the GPU commands
Additional notes
- Flax exposes Gamepad for Android device at index 0 which can be used to vibrate the device or read the Back key pressed by the user during gameplay
- To enable device vibrations add
android.permission.VIBRATE
to the permissions list in Android Platform Settings asset - To enable device network state reading add
android.permission.ACCESS_NETWORK_STATE
to the permissions list in Android Platform Settings asset