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:

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

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:
1dependencies {
2 implementation(files("libs/VLens-release.aar"))
3
4 implementation("com.github.mrmike:ok2curl:0.8.0")
5 implementation("androidx.fragment:fragment-ktx:1.8.5")
6 implementation("androidx.camera:camera-core:1.4.2")
7 implementation("androidx.camera:camera-lifecycle:1.4.2")
8 implementation("androidx.camera:camera-camera2:1.4.2")
9 implementation("androidx.camera:camera-view:1.4.2")
10 implementation("com.google.mlkit:face-detection:16.1.7")
11 implementation("com.google.mlkit:text-recognition:16.0.1")
12 implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
13 implementation("com.squareup.retrofit2:retrofit:2.9.0")
14 implementation("com.squareup.retrofit2:converter-gson:2.9.0")
15 implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.29")
16 implementation("com.google.zxing:core:3.3.0")
17}

Quick start

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

1import com.silverkey.vlens.VLensManager
2
3VLensManager().init(
4 context = this@MainActivity,
5 sdkConfig = VLensManager.SdkConfig(
6 transactionId = transactionId,
7 env = VLensManager.EnvironmentConfig(
8 apiBaseUrl = "https://api.vlenseg.com",
9 accessToken = accessToken,
10 refreshToken = refreshToken,
11 apiKey = "YOUR_API_KEY",
12 tenancyName = "YOUR_TENANT"
13 ),
14 getExtractedData = true,
15 defaultLocale = "en"
16 ),
17 onSuccess = { extractedData ->
18 val name = extractedData?.idFrontData?.name
19 Toast.makeText(this, "Verified: $name", Toast.LENGTH_SHORT).show()
20 },
21 onFaild = { errorCode, errorMsg ->
22 Toast.makeText(this, "Error $errorCode: $errorMsg", Toast.LENGTH_SHORT).show()
23 }
24)

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

1colors = VLensManager.Colors(
2 light = VLensManager.ColorConfig(
3 accent = "#4E5A78",
4 primary = "#397374",
5 secondary = "#FF4081",
6 background = "#FEFEFE",
7 dark = "#000000",
8 light = "#FFFFFF"
9 ),
10 dark = VLensManager.ColorConfig(
11 accent = "#FFC107",
12 primary = "#2196F3",
13 secondary = "#FF4081",
14 background = "#000000",
15 dark = "#FFFFFF",
16 light = "#000000"
17 )
18)

Verification modes

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

1VLensManager().init(
2 context = this,
3 sdkConfig = VLensManager.SdkConfig(
4 transactionId = transactionId,
5 isLivenessOnly = false,
6 isNationalIdOnly = false,
7 getExtractedData = true,
8 env = VLensManager.EnvironmentConfig(
9 apiBaseUrl = "https://api.vlenseg.com",
10 accessToken = accessToken,
11 refreshToken = refreshToken,
12 apiKey = "YOUR_API_KEY",
13 tenancyName = "YOUR_TENANT"
14 ),
15 defaultLocale = "ar"
16 ),
17 onSuccess = { data -> /* handle success */ },
18 onFaild = { code, msg -> /* handle failure */ }
19)

Handling results

onSuccessExtractData

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

1onSuccess = { extractedData ->
2 // Verification status
3 val verified = extractedData?.isDigitalIdentityVerified
4
5 // User profile
6 val user = extractedData?.user
7 println(user?.fullName)
8 println(user?.phoneNumber)
9 println(user?.emailAddress)
10 println(user?.idNumber)
11
12 // ID front
13 val front = extractedData?.idFrontData
14 println(front?.name) // Arabic full name
15 println(front?.nameEnglish) // Transliterated name
16 println(front?.idNumber)
17 println(front?.dateOfBirth)
18 println(front?.gender)
19 println(front?.govern)
20
21 // ID back
22 val back = extractedData?.idBackData
23 println(back?.maritalStatus)
24 println(back?.job)
25 println(back?.religion)
26 println(back?.idExpiry)
27 println(back?.releaseDate)
28}

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

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

Custom error messages

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

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.