-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Working for Android
To build your raylib game for Android you need a set of Android tools. Those tools are basically the Android SDK and Android NDK, including Android Platform Tools and also Java Runtime.
Step 1. Install Java Runtime 8 (JRE), Android Studio (Android SDK, Android NDK) and Apache Ant tools:
Download and Install Java SE Runtime Environment 8
Download and Install on C: Android Studio. Use Android Studio's SDK Manager to install the latest Android Platform Tools and desired SDKs and NDK.
Download and decompress on C: Apache Ant
Step 2. Create the following environment variables:
Android Studio installs the NDK in a ndk-bundle folder inside the SDK folder location (where ever you installed it).
ANDROID_HOME = C:\android-sdk
ANDROID_SDK_TOOLS = C:\android-sdk\platform-tools
ANDROID_NDK = C:\android-sdk\ndk-bundle
ANT_HOME = C:\apache-ant
To compile raylib src it's required to install a custom ndk standalone toolchain. Build toolchain with this command:
python %ANDROID_NDK%\build\tools\make_standalone_toolchain.py --arch arm --api 16 --install-dir=C:\android_toolchain_arm_api16
After that, just navigate from command line to folder raylib/src/
and execute Makefile with:
mingw32-make PLATFORM=PLATFORM_ANDROID
Remember to setup ANDROID_NDK
, ANDROID_TOOLCHAIN
property properly in the Makefile!
ANDROID_NDK = C:/android-sdk/ndk-bundle
ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
NOTE: libraylib.a will be generated in folder `raylib/release/android/armeabi-v7a/.
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_HOME = C:/android-sdk
ANDROID_NDK = $(ANDROID_HOME)/ndk-bundle
ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/26.0.3
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
JAVA_HOME = C:/PROGRA~1/Java/jdk1.8.0_152
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
Again, Notepad++ comes with an already prepared script to do that. Just open raylib/templates/simple_game/simple_game.c
and run Notepad++ script raylib_compile_android_project_run_log
.
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