Skip to content

Building Android

Taner Sener edited this page Jul 28, 2026 · 2 revisions

FFmpegKitNext for Android can be built with the recommended Nix wrapper or by calling the direct Android build script.

Before building, review Android Prerequisites. For the full Android option reference, see nix-android.sh.

Build With Nix

Use the Nix wrapper for normal builds, CI builds and reproducible host environments.

./nix-android.sh --list-profiles
./nix-android.sh -p android-r27d

The wrapper enters the selected Nix profile and then calls scripts/start-android.sh inside that environment.

Build Without Nix

If you maintain the Android SDK, NDK, JDK and host tools yourself, call the direct script from the project root:

./scripts/start-android.sh

The direct script uses the environment described in Android Prerequisites, especially ANDROID_SDK_ROOT, ANDROID_NDK_ROOT and JAVA_HOME.

Build Options

The same Android build options can be passed to both commands. For example:

./nix-android.sh -p android-r27d --enable-libwebp --disable-arm-v7a-neon
./scripts/start-android.sh --enable-libwebp --disable-arm-v7a-neon

Use --enable-gpl when enabling GPL-licensed libraries such as x264, x265, xvidcore, libvidstab or rubberband.

Use --prefab when the generated AAR should include Android Prefab metadata for native/CMake consumers. See Android Prefab for the generated modules, CMake integration pattern and test app.

The complete option list is documented in nix-android.sh.

Build Flow

The Android build has these phases:

  1. Build FFmpeg and enabled external libraries with the Android NDK toolchain.
  2. Build the native FFmpegKitNext Android library with ndk-build.
  3. Package the Kotlin/Java API and native libraries into an Android Archive (.aar) with the Gradle wrapper.
  4. If --prefab is enabled, inject the generated Prefab package into the AAR.

Build Output

Build outputs are written under prebuilt.

A default API 24 Android build creates a local Maven repository similar to:

prebuilt/bundle-android-aar-24-maven/
  com/arthenica/ffmpeg-kit-next/<version>/
    ffmpeg-kit-next-<version>.aar
    ffmpeg-kit-next-<version>.pom

Use the generated local Maven repository from your Android application or copy it into your own artifact repository.

When --prefab is enabled, the AAR inside that repository also contains a prefab/ directory for Android Gradle Plugin native consumers.

Clone this wiki locally