Android SDK

Integrate biometric verification and identity scanning into your Android app
View as Markdown

The VLens Android SDK embeds the full identity verification experience — national ID scanning, liveness detection, and face matching — directly into your Android app with a single method call.

Maven Central

vlens-sdk · v1.0.2

Min SDK

API 26 (Android 8.0)+

Language

Kotlin 1.9.10+, Target SDK 35


Installation

Add the dependency to your app’s build.gradle:

dependencies {
implementation("io.github.vlens2021:vlens-sdk:1.0.2")
}

All transitive dependencies (CameraX, ML Kit, Retrofit, etc.) are automatically included. You do not need to add them manually.

Method 2: Manual AAR

If you prefer to use the AAR file directly:

  1. Copy the VLens-release.aar file into your project’s app/libs/ directory.
  2. Add the file and its required dependencies to your build.gradle:
dependencies {
implementation(files("libs/VLens-release.aar"))
implementation("com.github.mrmike:ok2curl:0.8.0")
implementation("androidx.fragment:fragment-ktx:1.8.5")
implementation("androidx.camera:camera-core:1.4.2")
implementation("androidx.camera:camera-lifecycle:1.4.2")
implementation("androidx.camera:camera-camera2:1.4.2")
implementation("androidx.camera:camera-view:1.4.2")
implementation("com.google.mlkit:face-detection:16.1.7")
implementation("com.google.mlkit:text-recognition:16.0.1")
implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.29")
implementation("com.google.zxing:core:3.3.0")
}

Quick start

Import and call VLensManager().init() from your Activity or Fragment:

import com.silverkey.vlens.VLensManager
VLensManager().init(
context = this@MainActivity,
sdkConfig = VLensManager.SdkConfig(
transactionId = transactionId,
env = VLensManager.EnvironmentConfig(
apiBaseUrl = "https://api.vlenseg.com",
accessToken = accessToken,
refreshToken = refreshToken,
apiKey = "YOUR_API_KEY",
tenancyName = "YOUR_TENANT"
),
getExtractedData = true,
defaultLocale = "en"
),
onSuccess = { extractedData ->
val name = extractedData?.idFrontData?.name
Toast.makeText(this, "Verified: $name", Toast.LENGTH_SHORT).show()
},
onFaild = { errorCode, errorMsg ->
Toast.makeText(this, "Error $errorCode: $errorMsg", Toast.LENGTH_SHORT).show()
}
)

Configuration

EnvironmentConfig

ParameterTypeDescription
apiBaseUrlStringVlens API base URL — use https://api.vlenseg.com
accessTokenStringUser JWT from registration or login
refreshTokenStringToken used to refresh the access token
apiKeyStringYour tenant API key
tenancyNameStringYour tenant name

SdkConfig — all parameters

ParameterTypeDefaultDescription
transactionIdStringUnique identifier for the transaction
envEnvironmentConfigAPI credentials and endpoint
isLivenessOnlyBooleanfalseSkip ID scanning — liveness check only
isNationalIdOnlyBooleanfalseSkip liveness — ID scan only
getExtractedDataBooleanfalseReturn OCR-extracted fields in onSuccess
defaultLocaleString"en"UI language — "en" or "ar"
colorsColorsLight and dark theme colours
detectionRetryCounterInt5Liveness retries allowed before failure
disableAutoCaptureBooleanfalseRequire manual capture for ID front and back
errorMessagesList<ApiError>[]Override default error messages

Colors and ColorConfig

colors = VLensManager.Colors(
light = VLensManager.ColorConfig(
accent = "#4E5A78",
primary = "#397374",
secondary = "#FF4081",
background = "#FEFEFE",
dark = "#000000",
light = "#FFFFFF"
),
dark = VLensManager.ColorConfig(
accent = "#FFC107",
primary = "#2196F3",
secondary = "#FF4081",
background = "#000000",
dark = "#FFFFFF",
light = "#000000"
)
)

Verification modes

Runs the complete flow: ID front → ID back → liveness.

VLensManager().init(
context = this,
sdkConfig = VLensManager.SdkConfig(
transactionId = transactionId,
isLivenessOnly = false,
isNationalIdOnly = false,
getExtractedData = true,
env = VLensManager.EnvironmentConfig(
apiBaseUrl = "https://api.vlenseg.com",
accessToken = accessToken,
refreshToken = refreshToken,
apiKey = "YOUR_API_KEY",
tenancyName = "YOUR_TENANT"
),
defaultLocale = "ar"
),
onSuccess = { data -> /* handle success */ },
onFaild = { code, msg -> /* handle failure */ }
)

Handling results

onSuccessExtractData

When getExtractedData = true, the onSuccess callback receives an ExtractData object:

onSuccess = { extractedData ->
// Verification status
val verified = extractedData?.isDigitalIdentityVerified
// User profile
val user = extractedData?.user
println(user?.fullName)
println(user?.phoneNumber)
println(user?.emailAddress)
println(user?.idNumber)
// ID front
val front = extractedData?.idFrontData
println(front?.name) // Arabic full name
println(front?.nameEnglish) // Transliterated name
println(front?.idNumber)
println(front?.dateOfBirth)
println(front?.gender)
println(front?.govern)
// ID back
val back = extractedData?.idBackData
println(back?.maritalStatus)
println(back?.job)
println(back?.religion)
println(back?.idExpiry)
println(back?.releaseDate)
}

ExtractData — full field reference

user

FieldType
idInt
nameString
surnameString
fullNameString
userNameString
emailAddressString
phoneNumberString
idNumberString
addressString

idFrontData

FieldType
nameString — Arabic full name
nameEnglishString — Transliterated name
firstName / lastNameString
firstNameEnglish / lastNamesEnglishString
idNumberString
idKeyString
dateOfBirthString
genderString
govern / governEnglishString
address / addressEnglishString
city / districtString
transactionId / requestIdString

idBackData

FieldType
maritalStatus / maritalStatusEnglishString
job / jobEnglishString
jobTitle / jobTitleEnglishString
religion / religionEnglishString
husbandName / husbandNameEnglishString
gender / genderEnglishString
releaseDateString
idExpiryString
idNumberString
transactionId / requestIdString

onFaild

onFaild = { errorCode, errorMsg ->
// Log or display the error
Log.e("VLens", "Error $errorCode: $errorMsg")
}

Custom error messages

errorMessages = listOf(
VLensManager.ApiError(
errorCode = 101,
errorMessageEn = "Network error. Please check your connection.",
errorMessageAr = "خطأ في الشبكة. يرجى التحقق من الاتصال."
)
)

Security notes

  • Store API credentials (access token, refresh token, API key) securely — never hardcode them in production builds.
  • Use Android Keystore or a secrets management solution for runtime credential storage.

Support

For issues or inquiries, contact support@vlenseg.com with your tenant name, the error code and message, and the SDK version.