Environment Setup

Android NDK

Download from NDK Downloads and set environment variable:
bash
export ANDROID_NDK_HOME=/path/to/your/android-ndk

Android SDK

Install command-line tools from Android Studio Downloads or via sdkmanager.

Build llama.cpp for Android

bash
cd third-party/llama.cpp
cmake \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28 \
  -DGGML_OPENMP=OFF \
  -DGGML_LLAMAFILE=OFF \
  -DLLAMA_CURL=OFF \
  -B build-android
cd build-android
cmake --build . -j8

Build nexaml for Android

bash
cd backends/nexaml/interface
cmake \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28 \
  -DGGML_OPENMP=OFF \
  -DGGML_LLAMAFILE=OFF \
  -DLLAMA_CURL=OFF \
  -B build-android
cd build-android
cmake --build . -j8

Configure Android Project

Create or edit bindings/android/local.properties:
properties
sdk.dir=/your/path/to/android-sdk
ndk.dir=/your/path/to/android-ndk

Build the AAR

bash
cd bindings/android
./gradlew :app:assembleRelease
The .aar file will be at app/build/outputs/aar/

Integration

Copy the .aar into your app’s libs/ folder and update build.gradle:
groovy
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.aar'])
}