Note: Due to an upstream bug, you will probably receive a warning (or multiple warnings if building for multiple targets) like this:
error: warning(link): unexpected LLD stderr:
ld.lld: warning: <path-to-project>/.zig-cache/o/4227869d730f094811a7cdaaab535797/libraylib.a: archive member '<path-to-ndk>/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/35/libGLESv2.so' is neither ET_REL nor LLVM bitcode
You can ignore this error for now, or see this PR for the changes you can make locally to your std lib to fix the error.
zig build run # Native
zig build run -Dandroid # Android - Also installs & runs the appzig build -Dtarget=x86_64-linux-android
adb install ./zig-out/bin/loki-android.apk
adb shell am start -S -W -n com.zig.loki/android.app.NativeActivityzig build -Dandroid
adb install ./zig-out/bin/loki-android.apkIf installing your application fails with something like:
adb: failed to install ./zig-out/bin/loki-android.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.zig.loki signatures do not match newer version; ignoring!]
adb uninstall "com.zig.loki"Powershell (app doesn't need to be running)
adb logcat | Select-String com.zig.loki:Bash (app doesn't need running to be running)
adb logcat com.zig.loki:D *:SBash (app must be running, logs everything by the process including modules)
adb logcat --pid=`adb shell pidof -s com.zig.loki`- Install the JAVA SDK from https://www.oracle.com/java/technologies/downloads/
- I used the
.tar.gzand unpacked it to~/.local/apps/jdk-24.0.2
- I used the
- Install the android cmdline-tools
(use the non-Android Studio tarball option) to
~/.local/apps/android-sdk/cmdline-tools/latest/
export JDK_HOME=${HOME}/.local/apps/jdk-25.0.2
export ANDROID_HOME=${HOME}/.local/apps/android-sdk/
# IMPORTANT: This Java version must be found first within your PATH!
export PATH=${JDK_HOME}/bin:${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}
sdkmanager --install "build-tools;35.0.1"
sdkmanager --install "ndk;29.0.13113456"
sdkmanager --install "platforms;android-35"
sdkmanager --install "platform-tools"
export PATH=${ANDROID_HOME}/platform-tools:${PATH}
sudo usermod -aG plugdev $USERUbuntu:
sudo apt install -y libglx-dev libx11-6 libx11-dev libx11-xcb-dev libxcursor-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev
