|
|
@ -1,60 +1,68 @@ |
|
|
|
To build your raylib game for Android you need a different compiler than the one that comes with raylib installation, actually, you need a set of tools. Those tools are basically the Android SDK and Android NDK. |
|
|
|
To build your raylib game for Android you need a different compiler than the one that comes with raylib installation, actually, you need a set of tools. Those tools are basically the Android SDK and Android NDK that can be install from Android Studio's built in SDK Manager. |
|
|
|
|
|
|
|
### Installing Android tools |
|
|
|
|
|
|
|
_Step 1._ Install Java Runtime 8 (JRE), Android SDK, Android NDK and Apache Ant tools: |
|
|
|
_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](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html) |
|
|
|
|
|
|
|
> Download and decompress on C: [Android SDK](https://dl.google.com/android/repository/sdk-tools-windows-3859397.zip) |
|
|
|
> Download and Install on C: [Android Studio](https://dl.google.com/dl/android/studio/install/3.0.1.0/android-studio-ide-171.4443003-windows.exe). |
|
|
|
Use Android Studio SDK Manager to install the latest Android Platform Tools and desired SDK's and NDK. |
|
|
|
|
|
|
|
> Download and decompress on C: [Android NDK](https://dl.google.com/android/repository/android-ndk-r14b-windows-x86.zip) |
|
|
|
> Download and decompress on C: [Apache Ant](http://www-eu.apache.org/dist//ant/binaries/apache-ant-1.10.1-bin.zip) |
|
|
|
|
|
|
|
> Download and decompress on C: [Apache Ant](http://apache.rediris.es//ant/binaries/apache-ant-1.9.6-bin.zip) |
|
|
|
|
|
|
|
_Step 2._ Create the following environment variables with the correct paths: |
|
|
|
_Step 2._ Create the following environment variables (Asumming android-sdk is where Android Studio: |
|
|
|
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_ROOT = C:\android-ndk |
|
|
|
ANDROID_NDK = C:\android-sdk\ndk-bundle |
|
|
|
ANT_HOME = C:\apache-ant |
|
|
|
|
|
|
|
_Step 3._ Make sure latest Android Platform Tools and desired SDKs are installed, use SDK Manager tool: |
|
|
|
|
|
|
|
C:\android-sdk\SDK Manager.exe |
|
|
|
|
|
|
|
### Compiling raylib source code |
|
|
|
|
|
|
|
To compile raylib src it's required to install a [custom ndk standalone toolchain](https://developer.android.com/ndk/guides/standalone_toolchain.html). |
|
|
|
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_TOOLCHAIN` property properly in the Makefile!** |
|
|
|
**Remember to setup `ANDROID_NDK` `ANDROID_TOOLCHAIN` property properly in the Makefile!** |
|
|
|
|
|
|
|
NOTE: libraylib.a will be generated in folder `raylib/release/android/armeabi-v7a/`, it must be copied |
|
|
|
to Android project; if using `raylib/template_android` project, copy it to `raylib/template_android/jni/libs/`. |
|
|
|
ANDROID_NDK = C:/android-sdk/ndk-bundle |
|
|
|
ANDROID_TOOLCHAIN = C:/android_toolchain_arm_api16 |
|
|
|
|
|
|
|
### Compiling raylib game for Android (using project template) |
|
|
|
NOTE: libraylib.a will be generated in folder `raylib/release/android/armeabi-v7a/. |
|
|
|
|
|
|
|
_Step 1._ To compile project, navigate from command line to folder `raylib/template/android_project/jni/` and type: |
|
|
|
### Compiling a raylib game for Android (using an example project template) |
|
|
|
|
|
|
|
%ANDROID_NDK_ROOT%\ndk-build |
|
|
|
_Step 1._ To build an APK, navigate to folder `raylib/template/simple_game/` and edit Makefile.Android. Replace these |
|
|
|
settings with yours where apropriate: |
|
|
|
|
|
|
|
_Step 2._ To generate APK, navigate to folder `raylib/template/android_project/jni/` and type: |
|
|
|
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 |
|
|
|
|
|
|
|
%ANT_HOME%\bin\ant debug |
|
|
|
Then build the apk with: |
|
|
|
|
|
|
|
mingw32-make PLATFORM=PLATFORM_ANDROID |
|
|
|
|
|
|
|
_Step 3:_ To install APK into connected device (previously intalled drivers and activated USB debug mode on device): |
|
|
|
_Step 2:_ To install the APK into connected device (previously intalled drivers and activated USB debug mode on device): |
|
|
|
|
|
|
|
%ANT_HOME%\bin\ant installd |
|
|
|
%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/android_project/jni/basic_game.c` and run Notepad++ script `raylib_compile_android_project_run_log`. |
|
|
|
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][raysan5].** |
|
|
|