Requirements
- CMake 3.22.1+
- NDK r25+
- Ninja 1.10+
- Android SDK Build-Tools 34.0.0+
- Android Studio (with SDK Platforms API 26+, Build-Tools, Platform-Tools, SDK Tools, NDK, and CMake installed via SDK Manager)
Environment Setup
Ensure ANDROID_SDK_ROOT and ANDROID_NDK_HOME are set, and that build tools are in your PATH.
Building Binaries (No APK)
To build binaries like vulkaninfo or libVkCube for a specific ABI using CMake:
cmake -S . -B build \
-D CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-D ANDROID_PLATFORM=26 \
-D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \
-D CMAKE_ANDROID_STL_TYPE=c++_static \
-D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \
-D CMAKE_BUILD_TYPE=Release \
-D UPDATE_DEPS=ON \
-G Ninja
cmake --build build
Alternatively, use the scripts/android.py helper script:
# Build release binaries for arm64-v8a
python3 scripts/android.py --config Release --app-abi arm64-v8a --app-stl c++_static
# Build release binaries for all ABIs
python3 scripts/android.py --config Release --app-abi 'armeabi-v7a arm64-v8a x86 x86_64' --app-stl c++_static
Building the VkCube APK
Use scripts/android.py with the --apk flag to handle the complex process of wrapping CMake and Android CLI tools:
# Build a complete APK with debug binaries for all ABIs
python3 scripts/android.py --config Debug --app-abi 'armeabi-v7a arm64-v8a x86 x86_64' --app-stl c++_shared --apk
# Build a clean APK with release binaries for arm64-v8a
python3 scripts/android.py --config Release --app-abi arm64-v8a --app-stl c++_shared --apk --clean
Note: APKs are placed in the build-android/bin directory.
python3 scripts/android.py --config Release --app-abi arm64-v8a --app-stl c++_static