Melange
Platform IntegrationAndroid

Setup

Set up ZETIC Melange in your Android project.

This guide walks you through adding the ZETIC Melange SDK to your Android project. Melange abstracts the complexity of NPU execution: you do not need to write any C++ or OpenCL code.

Prerequisites

  • Android Studio Arctic Fox or later
  • A physical Android device (emulators do not have NPU hardware)
  • Minimum SDK 24 (Android 7.0)
  • A Personal Key from the Melange Dashboard

Your project structure should look like this:

build.gradle
MainActivity.kt
build.gradle
settings.gradle

Add Melange Dependency

Integrate the Melange AAR (Android Archive) which contains the Unified HAL for Android devices.

build.gradle.kts

android {
    ...
    packaging {
        jniLibs {
            useLegacyPackaging = true
        }
    }
}

dependencies {
    implementation("com.zeticai.mlange:mlange:+")
}

build.gradle

android {
    ...
    packagingOptions {
        jniLibs {
            useLegacyPackaging true
        }
    }
}

dependencies {
    implementation 'com.zeticai.mlange:mlange:+'
}

The useLegacyPackaging setting is required. It ensures the native C++ NPU drivers (JNI) are correctly bundled without compression. Without it, you will get a java.lang.UnsatisfiedLinkError at runtime.

Sync and Build

  1. Click Sync Now in the Gradle notification bar.
  2. Build your project to verify the dependency resolves correctly.

Verify Setup

Add a simple initialization test to confirm the SDK is working:

import com.zeticai.mlange.ZeticMLangeModel

// Test initialization (use in onCreate or a background thread)
val model = ZeticMLangeModel(this, PERSONAL_KEY, MODEL_NAME)

If the initialization completes without error, your setup is ready.

The constructor performs a network call on first use to download the model binary. Call it from a background thread or use Kotlin coroutines to avoid blocking the UI.


Next Steps