Compiling for Android¶
Compiling from Windows¶
You need a complete Android development environment, including the Android SDK and Android NDK.
- Cygwin (base settings for Bash scripts)
Installing OpenJDK or Oracle JDK¶
Download the setup tool from the official webpage and install the base distribution.
You can install Windows git or add the cygwin git version from the cygwin installer.
Next step: From here, follow the instructions for compiling Android from Linux.¶
Compiling from Linux¶
You need a complete android development environment ready to develop native apps. That means you have:
Use Google to figure out how to install that and make sure the appropriate executables from the above are in your path variable.
These instructions have been tested under Linux (Fedora 20 and Ubuntu 18.04). They may also work in windows with cygwin.
Getting the code¶
1 2 3
./libretro-fetch.sh can fail on
fork() calls, repeat until all are up to date. For
./libretro-build-android-mk.sh, some cores may fail to compile (g++ "Argument list too long" error).
Building the cores¶
For the core building portion of this tutorial, you'll need to put at least your NDK dir in the PATH variable for the build script to work. Just for the heck of it, I also like to throw in the tools folder from SDK as well as the build-tools (adjust to your situation):
Run build script ( read notes below before running the script):¶
You can omit
NOCLEAN=1 if you'd like to perform make clean on every core's repo before building each.
For a variety of reasons, some of the cores may not be compiled by the script. These reasons can range from: core folder doesn't have a libretro/jni folder setup yet, core's libretro/jni folder is in a place that the script does not expect, core has been recently added to project and has not yet been added to script or you're missing some essential dependencies and the build script failed. Some cores (like snes9x2002) need an older NDK. Some core don't use jni but use make or cmake instead.
In the event you are missing a core that you want, you can build it in most cases by going to its subfolder (libretro-corename) and performing this series of commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
You may also want to check this repo for a list of dependencies needed to build the cores:
1 2 3 4 5
more info about core building can be had here:
The RetroArch repo is fetched into the libretro-super folder by
You first need to fetch the submodules for it.
Now go to the project folder:
Within this folder, edit
local.properties to point to the location of your sdk and ndk directories by adding lines that look like this:
Eg. if you have Android Studio, your dirs should be in :
If you want to build a release apk (aka an apk with none of the debug layers), you'll have to self sign it. Make a file called
keystore.properties with the following content:
1 2 3 4
Next, generate a keystore file and be sure to put it where
keystore.properties says it is:
Now all the generated release apk will be automatically signed by gradle.
Next, copy the cores, assets and overlays to an assets folder you create here:
1 2 3 4 5
Optionally, you may want to include the assets for the front-end (menu icons, fonts, images etc), shader caches, dbs, cheats, etc... These assets can be downloaded at any time during run time via the updater but if you want to bundle them into the build you may do so by downloading bundle.zip / cheats.zip and extracting them to assets folder:
1 2 3 4 5
NOTE ABOUT BUNDLED ASSETS AND CORES
I've sometimes noticed a bug where the built apk does not unpack the bundled assets and cores on first install. My workaround was to re-install the apk a second time. On the second install, the assets and cores get unpacked. This is a bug in 1.7.7 and 1.7.8.
Now run gradlew and let it configure and sync itself and download all it's dependencies:
Optionally: You can get a list of available tasks by doing:
Now, if all went smoothly with config step, you can proceed to build the apk
1 2 3 4 5 6 7 8
If all goes well, this will spit out an .apk. For example
build/outputs/apk/normal/debug/phoenix-normal-debug.apk. Put it on your device with
You can find all the apks built by gradle with this command (execute from the same dir as gradlew)"
This should give you a list of all the outputted apks.