Build and run seekdb on Android
Cross-compile seekdb for Android arm64-v8a on macOS, then deploy it to an emulator or physical device.
Prerequisites
- macOS host
- Android NDK 27.x, with
ANDROID_NDK_HOMEset to its installation directory - An arm64-v8a device or emulator running API 28 or later
adband a MySQL-compatible client onPATH
Build
Set the installed NDK path, initialize Android dependencies, then build with Bazel:
export ANDROID_NDK_HOME="$HOME/Library/Android/sdk/ndk/27.3.13750724"
python3 build.py init --android
python3 build.py build --config=android seekdb
init --android prepares host tools in deps/3rd and Android dependencies in
deps/android, and installs the Android target for the pinned Rust toolchain.
Native and Android builds can share one checkout.
The binary is generated at:
This configuration produces an API 28 ARM64 PIE with 16 KiB page alignment and a statically linked C++ runtime. Validate affected unit tests on a supported Linux host by following Write and run unit tests.
Strip and deploy
Use the NDK strip tool because the macOS strip command cannot process Android ELF binaries:
NDK_STRIP="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip"
"$NDK_STRIP" -o /tmp/seekdb build/bin/src/observer/seekdb
adb push /tmp/seekdb /data/local/tmp/seekdb
adb shell chmod +x /data/local/tmp/seekdb
For an Apple Silicon NDK installation, use the actual prebuilt host directory present under $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/.
Start and connect
Choose resource values that fit the device:
adb shell "mkdir -p /data/local/tmp/seekdb_data"
adb shell "/data/local/tmp/seekdb --nodaemon \
--base-dir /data/local/tmp/seekdb_data \
--parameter memory_budget=4G \
--parameter datafile_size=2G \
--parameter datafile_maxsize=4G \
--parameter log_disk_size=2G \
--log-level INFO"
Forward the SQL port and connect:
Inspect logs and stop the process with: