Setup
Set up ZETIC Melange in your Android project.
This guide targets ZeticMLange Android 1.11.0 — the recommended version and the one all API reference pages are written against.
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:
Add Melange Dependency
The Android SDK is published as Gradle artifacts in the public ZeticMLangeAndroid GitHub release. Add its Ivy repository to your project-level settings.gradle.kts (or merge the ivy entry into your existing dependency repositories):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
ivy {
name = "ZeticMLangeAndroidGitHubRelease"
url = uri("https://github.com/zetic-ai/ZeticMLangeAndroid/releases/download")
patternLayout {
artifact("[revision]/[artifact]-[revision](-[classifier]).[ext]")
}
metadataSources {
gradleMetadata()
}
content {
includeGroup("com.zeticai.mlange")
includeGroup("com.zeticai.mlange.backend")
}
}
}
}Google and Maven Central remain configured for the SDK's public transitive dependencies. The Ivy repository serves the Android SDK artifacts.
Integrate the Melange AAR (Android Archive), which contains the Unified HAL for Android devices, in your app module:
build.gradle.kts
android {
...
packaging {
jniLibs {
useLegacyPackaging = true
}
}
}
dependencies {
implementation("com.zeticai.mlange:mlange:1.11.0")
}build.gradle
android {
...
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}
dependencies {
implementation 'com.zeticai.mlange:mlange:1.11.0'
}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
- Click Sync Now in the Gradle notification bar.
- 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.core.model.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.