Updated Working for Android (markdown)

Ray
2020-03-05 12:34:22 +01:00
parent ec4fbd0d12
commit 8abcef37ac

@ -4,9 +4,9 @@
Android requires a set of tools to do all the build process to generate a .APK game. Android requires a set of tools to do all the build process to generate a .APK game.
### 1. Java 8 JDK (including JRE) ### 1. Open JDK
You can just download the JDK from [here](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and install it or alternatively, you can create a portable install [just decompressing required files](https://www.whitebyte.info/programming/java/how-to-install-a-portable-jdk-in-windows-without-admin-rights). You can just download the JDK from [here](https://jdk.java.net/13/) and decompress it in a directory, raylib `Makefile.Android` scripts looks for it on `C:\open-jdk`.
### 2. Android SDK ### 2. Android SDK
@ -19,50 +19,40 @@ Alternatively, you can just install the required files manually. To do that, sta
``` ```
sdkmanager --update sdkmanager --update
sdkmanager --list sdkmanager --list
sdkmanager --install build-tools;28.0.1 sdkmanager --install build-tools;29.0.3
sdkmanager --install platform-tools sdkmanager --install platform-tools
sdkmanager --install platforms;android-21 sdkmanager --install platforms;android-28
sdkmanager --install extras;google;usb_driver 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). With those commands you're installing all required tools. It includes: `tools`, `build-tools`, `platform-tools`, `platforms\android-28` api level and also `extras\google\usb_driver` (that you need to install to connect to your device).
### 3. Android NDK ### 3. Android NDK
To develop with raylib in C, we need to install the Android Native Development Kit. You can download it from [here](https://developer.android.com/ndk/downloads/). 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. To develop with raylib in C, we need to install the Android Native Development Kit. You can download it from [here](https://developer.android.com/ndk/downloads/). Android NDK includes support files for multiple Android APIs and multiple architectures. raylib scripts expect to use NDK r21 and found it available on `C:\android-ndk-r21`.
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
## Compiling raylib source code ## Compiling raylib source code
To compile raylib sources, it's recommended to use [Android NDK standalone toolchain](https://developer.android.com/ndk/guides/standalone_toolchain.html). To compile raylib sources, just navigate from command line to folder `raylib/src/` and execute `Makefile` with:
Once the toolchain is avaliable, just navigate from command line to folder `raylib/src/` and execute Makefile with:
mingw32-make PLATFORM=PLATFORM_ANDROID mingw32-make PLATFORM=PLATFORM_ANDROID
Remember to setup `ANDROID_TOOLCHAIN` path property in the Makefile! NOTE: libraylib.a will be generated in `raylib/src` directory by default.
ANDROID_TOOLCHAIN = C:/android_toolchain_ARM_API21 WARNING: Maybe your Android device uses a 64bit CPU but be careful, installed Android OS could still be 32bit, not allowing 64bit apps.
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.
## Compiling a raylib game for Android (using an example project template) ## Compiling a raylib game for Android (using an example project template)
_Step 1._ To build an APK, navigate to folder `raylib/template/simple_game/` and edit Makefile.Android. Replace these _Step 1._ To build an APK, navigate to folder `raylib/template/simple_game/` and edit Makefile.Android. Replace these
settings with yours where apropriate: settings with yours where apropriate:
``` ```
ANDROID_ARCH ?= ARM ANDROID_ARCH ?= ARM
ANDROID_API_VERSION = 21 ANDROID_API_VERSION = 28
JAVA_HOME ?= C:/JavaJDK JAVA_HOME ?= C:/open-jdk
ANDROID_HOME = C:/android-sdk ANDROID_HOME = C:/android-sdk
ANDROID_TOOLCHAIN = C:/android_toolchain_$(ANDROID_ARCH)_API$(ANDROID_API_VERSION) ANDROID_TOOLCHAIN = C:/android-ndk-r21/toolchains/llvm/prebuilt/windows-x86_64
ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/28.0.1 ANDROID_BUILD_TOOLS = $(ANDROID_HOME)/build-tools/29.0.3
ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools ANDROID_PLATFORM_TOOLS = $(ANDROID_HOME)/platform-tools
``` ```
Then build the apk with: Then build the apk with:
@ -70,7 +60,7 @@ Then build the apk with:
_Step 2:_ To install the 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):
%ANDROID_SDK_TOOLS%\adb install -r simple_game.apk %ANDROID_SDK_TOOLS%\adb install simple_game.apk
_Step 4:_ To view log output from device: _Step 4:_ To view log output from device:
@ -79,5 +69,5 @@ _Step 4:_ To view log output from device:
**If you have any doubt, [just let me know][raysan5].** **If you have any doubt, [just let me know][raysan5].**
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San" [raysan5]: mailto:ray@raylib.com