Feathers UI may be used to build mobile applications targeting Google's Android operating system.
In addition to the dependencies specified in the Feathers UI installation instructions, building an Android application with Feathers UI has some additional requirements.
Install the Java OpenJDK (version 8 or newer)
- Launch Android Studio at least once to go through its setup wizard that downloads the Android SDK components.
Download Android NDK r15c (do not download a newer NDK version)
- Extract the archive somewhere on your file system, and take note of the absolute path because it will be used in a later step.
Configure OpenFL for Android
To set the locations of various tools required to build Android apps, you need to run the following command:
openfl setup android
It will request the paths to several of the required tools that were installed in previous steps.
Pass in the absolute path of the Android SDK.
Run Android Studio at least one time to go through its setup wizard that downloads the Android SDK components.
Typically, when the Android SDK is installed by Android Studio, it is located at a standard location on each platform:
- Windows: C:\Users\username\AppData\Local\Android\Sdk
- macOS: ~/Library/Android/sdk
- Linux: ~/Android/Sdk
Pass in the absolute path where you extracted the Android NDK.
The Java JDK may be installed in a variety of locations, depending on which operating system you are using:
- Windows: Typically, Java is installed to C:\Program Files\AdoptOpenJDK or C:\Program Files\Java
- macOS: Run the /usr/libexec/java_home command in the Terminal app to find the JDK location.
- Linux: Run the whereis java command in a terminal to find the JDK location.
JAVA_HOMEshould be set to parent of the bin folder that contains the java executable.
To build for the
android target, run the following command.
openfl build android
-debug flag to create a build to include extra debugging information, including full stack traces when there's an exception or crash.
openfl build android -debug
The build's output will be written to the bin/android/bin folder. The .apk file may be found in bin/android/bin/app/build/outputs/apk/debug (including release builds).
Your project.xml file may optionally specify an output folder different from bin.
In the example above, the output would be generated in Export/android/bin instead.
Error on macOS says executables from the Android NDK "cannot be opened because the developer cannot be verified"
You will need to manually allow these executables through macOS Gatekeeper.
In the error dialog, click Cancel and stop the current build in your terminal.
Open the System Preferences app.
Choose Security & Privacy.
Go to the General tab.
In the Allow apps downloaded from: section, click the Allow Anyway button.
Start the build again.
This time the pop-up will ask if you are sure that you want to open the executable. Click Open.
You may need to repeat this process many times, so keep the System Preferences app open so that you can click the Allow Anyway button when it appears again. The same executable name may fail more than once. This is normal. Android supports many CPU architectures, and each has its own set of executables.
Error: arm-linux-androideabi-g++: command not found
There is more than one possible reason for seeing this error:
You may have downloaded the wrong version of the Android NDK. You must use r15c specifically. Newer versions will not work.
You may have used the wrong path to the Android NDK on your file system. Check that the root folder of the SDK contains multiple sub-folders and files, including a README file.
Error: Failed to install the following Android SDK packages as some licences have not been accepted.
YOu may need to install a specific version of the Android SDK platform tools in Android Studio. The error message will include the version that you need, in a format like this:
platforms;android-28 Android SDK Platform 28
Open the Android Studio settings, and install the Android SDK platform tools with the specified API version. For the example above, API version 28 refers to Android 9.0 (Pie).
Did you get some other error message that you don't understand?
Configuring OpenFL to build for native targets, like iOS or Android, can be a little tricky! Head over to either the Feathers UI community forum or the Feathers UI Discord. Explain which command you tried to run, be sure to mention that you are targeting android, and post the error message (and any additional relevant output). Ideally, we can help you figure out a solution, and then we'll also add it to this troubleshooting section, so that everyone can benefit.