For the complete documentation index, see llms.txt. This page is also available as Markdown.
android

Handling Failures

Reference for Android Face Liveness failure handling. Learn LivenessFailure types, cause values, provider-specific errors, and how to map failures to clear user guidance.

When a liveness check fails, the SDK returns a LivenessFailure object. This object contains a cause parameter, which is a string identifier that tells you exactly why the process was unsuccessful.

Understanding and handling the cause parameter is critical for providing clear, actionable feedback to your users so they can correct the issue and try again.

The Failure Models

The SDK uses a sealed class hierarchy to categorize failures. Both capture-level and recognition-level failures inherit from the base LivenessFailure class, ensuring you can always access the cause string.

LivenessFailure.kt
public sealed class LivenessFailure(public open val cause: String) {
    
    // Triggered when the image capture process fails. No image (response) available
    public data class ImageCaptureFailure(override val cause: String) : LivenessFailure(cause)
    
    // Triggered when fails to recognize or authenticate the face.
    public data class FaceRecognitionFailure(
        public val response: String, 
        override val cause: String
    ) : LivenessFailure(cause)
}

Using the cause Parameter

The cause parameter returns a raw constant string (e.g., "TOO_DARK" or "FACE_TOO_FAR").

Best Practice: Do not display these raw strings directly to your end-users. Instead, intercept the cause string and map it to a user-friendly, localized message in your app's UI to guide them on how to fix the problem.

Available Failure Causes

When using the Iproov provider, if the image capture is successful but the engine fails to authenticate or process the face, the SDK returns a FaceRecognitionFailure.

Below is the list of possible cause values returned specifically during this phase:

Cause
Description

UNKNOWN

Generic failure

TOO_MUCH_MOVEMENT

Excessive head motion

TOO_BRIGHT

Over-illumination

TOO_DARK

Low light conditions

MISALIGNED_FACE

Face alignment failure

FACE_TOO_FAR

Face too distant

FACE_TOO_CLOSE

Face too close

SUNGLASSES

Eye-obscuring eyewear

OBSCURED_FACE

Partial face obstruction

EYES_CLOSED

Closed eyes during capture

MULTIPLE_FACES

Multiple faces detected

BACKGROUND_ISSUE

Unsuitable background

DEVICE_ISSUE

Incompatible device

EYEWEAR

Eyewear detected

FACE_NOT_FOUND

Face detection failure

FRAMES_BLURRY

Blurry frames detected

MOTION_ISSUE

Device motion error

LIGHTING_ISSUES

Poor lighting conditions

REJECTED

Transaction rejected

SYSTEM_ERROR

Internal system error

TIMEOUT

Session timeout

USER_NOT_FOUND

User lookup failure

DEVICE_RESTART

Device state error

PROCESSING_FAULT

Processing error

Example Implementation

Here is an example of how you might handle a LivenessFailure and map the cause parameter to helpful user guidance:

Last updated