Nosmai  Effects Nosmai  Moderation Nosmai Try-ons coming soon
Docs menu Android
Tutorial

Android quickstart

Initialize Nosmai Effects, connect your Camera2 source, show the processed preview, and apply a beauty effect on Android.

Platform Android SDK version 3.0.4 Updated Aug 22, 2026 Time 20 min

Prerequisites

1. Add manifest permissions

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

2. Initialize Nosmai once

Initialize from the application owner after loading the app-specific key:

NosmaiSDK.initialize(
    getApplicationContext(),
    BuildConfig.NOSMAI_LICENSE_KEY
);

Do not initialize from every activity or fragment. Continue only after camera permission is granted.

3. Add the preview

Add a container to the camera screen:

<FrameLayout
    android:id="@+id/preview_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Create one NosmaiPreviewView for that container and start processing:

FrameLayout container = findViewById(R.id.preview_container);
NosmaiPreviewView previewView = new NosmaiPreviewView(this);

container.addView(previewView);
previewView.enableOesInput(true);
NosmaiSDK.startProcessing(previewView);

4. Connect the Camera2 source

The Android SDK accepts Camera2 frames from the host application. Connect the front-camera capture session to the OES texture supplied by the preview:

previewView.addOnOesReadyListener(surfaceTexture -> {
    camera2Source.openFrontCamera(surfaceTexture);
});

camera2Source is the application's Camera2 owner. It must select a preview size, set sensor orientation, start one repeating capture request, and close the camera when the screen pauses. Reuse an existing camera component when the app already has one. Keep the Nosmai and regular camera sessions from owning the device at the same time.

5. Apply the first effect

Apply beauty after the processing pipeline is ready:

previewView.addOnPipelineReady(() -> {
    NosmaiBeauty.applySkinSmoothing(0.4f);
});

6. Release the camera

Close the Camera2 session before pausing the preview. Stop Nosmai processing when the camera screen is destroyed:

@Override
protected void onPause() {
    camera2Source.close();
    previewView.onPause();
    super.onPause();
}

@Override
protected void onDestroy() {
    NosmaiSDK.stopProcessing();
    super.onDestroy();
}

Run the screen on a physical arm64-v8a device. The full application structure, Camera2 helper, orientation handling, and OES fallback belong in the sample project rather than this quickstart.

Verify it worked

You should see the front-camera preview, the status Camera ready with skin smoothing, and a visible smoothing change at level 0.4. Move the app to the background and confirm the camera indicator turns off. Return and confirm the same preview resumes.

Common errors

ErrorCauseFix
License key cannot be null or emptyAndroid received an empty keySupply an app-bound key before calling NosmaiSDK.initialize
Preview view cannot be nullstartProcessing was called without a preview instanceCreate NosmaiPreviewView and pass that instance
Nosmai SDK is not initialized. Call NosmaiSDK.initialize() first.Processing started before initializationInitialize once before calling startProcessing
Camera device error: 2Camera2 reported ERROR_CAMERA_IN_USE, usually because another controller still owns the cameraStop and dispose the other camera before opening Nosmai
INSTALL_FAILED_NO_MATCHING_ABISDevice lacks arm64-v8aUse a physical ARM64 Android device

Next steps

References

Was this page helpful?

Your response helps us prioritize documentation improvements.

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved