-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Working for Android
NOTE: For alternative instructions, check Working for Android (on macOS).
Android requires a set of tools to do all the build process to generate a .APK game.
You can just download the JDK from here and install it or alternatively, you can create a portable install just decompressing required files.
Actually, Android SDK is composed by a series of tools, you can install everything in a go just downloading Android Studio and installing the full package.
Alternatively, you can just install the required files manually. To do that, start downloading Command line tools
package, found at the end of this page.
- Decompress downloaded
sdk-tools-...
file into a folder namedandroid-sdk
. One of the included tools is the sdkmanager, a command line utility to install required packages. - From command line, navigate to
android-sdk/tools/bin
and execute the following commands:
sdkmanager --update
sdkmanager --list
sdkmanager --install build-tools;28.0.1
sdkmanager --install platform-tools
sdkmanager --install platforms;android-21
sdkmanager --install extras;google;usb_driver
With those commands you're installing all required tools. It includes: tools
, build-tools
, platform-tools
, platforms\android-21
api and also extras\google\usb_driver
(that you need to install to connect to your device).
To develop with raylib in C, we need to install the Android Native Development Kit. You can download it from here. Android NDK includes support files for multiple Android APIs and multiple architectures; it is recommended to generate and standalone toolchain with just the required compiler and API you need.
Fortunately, Android NDK comes with a Python script that generates it for you, just execute the following command line:
python %ANDROID_NDK%\build\tools\make_standalone_toolchain.py --arch arm --api 21 --install-dir=C:\android_toolchain_ARM_API21
To compile raylib sources, it's recommended to use Android NDK standalone toolchain.
Once the toolchain is avaliable, just navigate from command line to folder raylib/src/
and execute Makefile with:
mingw32-make PLATFORM=PLATFORM_ANDROID
Remember to setup ANDROID_TOOLCHAIN
path property in the Makefile!
ANDROID_TOOLCHAIN = C:/android_toolchain_ARM_API21
NOTE: libraylib.a will be generated in folder raylib/release/android/armeabi-v7a/
or raylib/release/android/arm64-v8a/
, depending on the selected architecture (32bit or 64bit).
NOTE: Probably your Android device uses a 64bit CPU but be careful, installed Android OS could still be 32bit, not allowing 64bit apps.
Step 1. To build an APK, navigate to folder raylib/template/simple_game/
and edit Makefile.Android. Replace these
settings with yours where apropriate:
ANDROID_ARCH ?= ARM
ANDROID_API_VERSION = 21
JAVA_HOME ?= C:/JavaJDK
ANDROID_HOME = C:/android-sdk
ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION)
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
Then build the apk with:
mingw32-make PLATFORM=PLATFORM_ANDROID
Step 2: To install the APK into connected device (previously intalled drivers and activated USB debug mode on device):
%ANDROID_SDK_TOOLS%\adb install -r simple_game.apk
Step 4: To view log output from device:
%ANDROID_SDK_TOOLS%\adb logcat -c
%ANDROID_SDK_TOOLS%\adb -d logcat raylib:V *:S
If you have any doubt, just let me know.
www.raylib.com | itch.io | GitHub | Discord | YouTube
- Architecture
- Syntax analysis
- Data structures
- Enumerated types
- External dependencies
- GLFW dependency
- libc dependency
- Platforms and graphics
- Input system
- Default shader
- Custom shaders
- Coding conventions
- Integration with other libs
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on Chrome OS
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working on exaequOS Web Computer
- Creating Discord Activities
- Working anywhere with CMake
- CMake Build Options
- raylib templates: Get started easily
- How To: Quick C/C++ Setup in Visual Studio 2022, GCC or MinGW
- How To: C# Visual Studio Setup
- How To: VSCode
- How To: Eclipse
- How To: Sublime Text
- How To: Code::Blocks