Skip to content
imaged
Docs / Setup / Java

Java setup.

Drop imaged.aar into app/libs/, call ImagedSDK from any Activity or service.

Prerequisites
Android Gradle Plugin 8.2 or later
minSdk 24 (Android 7.0)
NDK Bundled with the AAR; no separate install needed
License token JWT issued from /dashboard
  1. 01

    Download the AAR

    Grab imaged.aar from the downloads page. Drop it into your app module under app/libs/. The AAR carries libsdk.so for arm64-v8a and x86_64, plus libonnxruntime and OpenCV.

    bash
    mkdir -p app/libs
    cp ~/Downloads/imaged.aar app/libs/
  2. 02

    Wire up Gradle

    Tell Gradle to pull AARs from app/libs/. Keep .onnx files uncompressed so the SDK can mmap them at run time.

    kotlin
    // app/build.gradle.kts
    android {
        namespace = "com.acme.detector"
        compileSdk = 36
        defaultConfig { minSdk = 24 }
    
        androidResources {
            @Suppress("UnstableApiUsage")
            noCompress += "onnx"
        }
        packaging {
            jniLibs { useLegacyPackaging = true }
        }
    }
    
    dependencies {
        implementation(fileTree("libs") { include("*.aar") })
    }
  3. 03

    Hello world

    Load the native libs once with ImagedLoader, construct ImagedSDK, set the license, verify it. The license must be checked before any family call.

    java
    import dev.imaged.sdk.ConfigurationOptions;
    import dev.imaged.sdk.ImagedLoader;
    import dev.imaged.sdk.ImagedSDK;
    
    public class Detector {
        public Detector(android.content.Context ctx) {
            ImagedLoader.load(ctx);
    
            ImagedSDK ai = new ImagedSDK();
            ConfigurationOptions cfg = ai.getOptions();
            cfg.setString("license.token", "your-license-token");
            cfg.setString("license.audience", "cameras.acme.com");
    
            int status = cfg.checkLicense();
            if (status != ConfigurationOptions.STATUS_SUCCESS || !ai.isLicensed()) {
                throw new IllegalStateException("license check failed, status " + status);
            }
    
            android.util.Log.i("imaged", "version " + ai.getVersion());
        }
    }
  4. 04

    Run a family

    detect returns a ResponseObject with a typed objects array. Image is AutoCloseable; wrap it in try-with-resources to free native pixels.

    java
    import dev.imaged.sdk.ColorCode;
    import dev.imaged.sdk.Image;
    import dev.imaged.sdk.ResponseObject;
    
    cfg.setString("yolo.model", modelPath);
    cfg.setString("yolo.inference.provider", "cpu");
    
    try (Image img = new Image()) {
        img.setData(rgbaBytes, width, height, ColorCode.RGBA);
        ResponseObject r = ai.detect("yolo", img);
        if (r.objects != null) {
            for (var obj : r.objects) {
                android.util.Log.i("imaged", obj.label + " " + obj.score);
            }
        }
    }
  5. 05

    Where to go next

    The Android example wires CameraX into the same calls. Read CameraDetector.kt for the production-ready pattern (Kotlin, but every API name maps directly).