Android SDK Integration
Capturing faces for FaceAuthen with the CAKE eKYC Android SDK, version 1.1.9. The entry point is CakeEkyc.
Build Specifications
| What | Description |
|---|---|
| Gradle | 7.4 |
| minSdkVersion | 21 |
| targetSdkVersion | 33 |
| Kotlin | 1.7.10 |
Add Dependencies
groovy
dependencies {
val core_version = "1.0.0"
val ui_version = "1.0.2"
val image_quality_version = "1.0.3"
val ekyc_version = "1.1.8"
implementation("vn.cake.ekyc.sdk:ekyc-core:$core_version")
implementation("vn.cake.ekyc.sdk:ekyc-ui:$ui_version")
implementation("vn.cake.ekyc.sdk:image-quality:$image_quality_version")
implementation("vn.cake.ekyc.sdk:ekyc:$ekyc_version")
}Initialize
kotlin
private val logger = object : Logger {
override fun info(log: String) {}
override fun error(log: String) {}
override fun warning(log: String) {}
}
val config = Config.Builder().apply {
withLanguage("vi")
withBaseUrl("<BASE_URL>")
withToken(TokenProvider.from("<ACCESS_TOKEN>"))
withLogger(logger)
}.build()
val ekycFuture = CakeEkyc.getInstance(applicationContext, config, executor)
val cakeEkyc = ekycFuture.get()Capture Faces
kotlin
val config = TakeFaceConfig(captureOnly = false, loadingView = customLoadingView)
val listener = object : FaceCapturingListener {
override fun onEvent(event: EkycEvent) {}
override fun onError(error: EkycError) {}
override fun onSuccess(result: SelfieResult) {}
}
cakeEkyc.takeFaces(activity, config, listener)SelfieResult carries the captured faces, the per-image sanityResult, and the livenessResult.
| Field | Type | Description |
|---|---|---|
faces | List<Face>? | Captured faces, each with image and gesture. |
sanityResult | List<EkycResponse<FaceSanityData>>? | Sanity response per image. |
livenessResult | EkycResponse<FaceLivenessData>? | Liveness result. |
Take face.image.id from each entry and pass those as the faces array to Register Faces or Verify Face Authen.
Errors
| Field | Type | Description |
|---|---|---|
EkycError.UserCanceledError | 40001 | User pressed back. |
EkycError.TimeoutError | 40000 | Timeout. |
EkycError.CameraError | 40003 | Opening the camera failed. |
EkycError.PermissionNotGranted | 40002 | Permissions were not granted. |
EkycError.QualityFailed | 60002 / 60003 | FACE_SANITY_FAILED or FACE_LIVENESS_FAILED. |
EkycError.UnexpectedError | 50000 | Runtime exception. |
Upload Image
When you capture outside the SDK, upload the bytes yourself.
kotlin
val uploadResult = ekyc.upload(image = bitmap, label = "portrait", metaData = metaData)
val imageId = when (uploadResult) {
is Result.Success -> uploadResult().data?.imageId
is Result.Fail -> throw uploadResult.error
}ByteArray is also accepted: ekyc.upload(data = byteArray, label = "portrait", metaData = metaData).
Individual Checks
Useful when you drive the pipeline yourself rather than calling takeFaces.
kotlin
val faceSanityResult = ekyc.checkFaceSanity(imageId = "<IMAGE_ID>")
val faceLivenessResult = ekyc.checkLiveness(imageIds = listOf("<IMAGE_ID>"))
val comparedResult = ekyc.compareFaces(imageId1 = "<IMAGE_ID_1>", imageId2 = "<IMAGE_ID_2>")compareFaces performs a 1:1 comparison and is independent of FaceAuthen — Verify Face Authen matches against the enrolled profile instead.
Next Steps
- Mobile SDK Overview — concepts shared across platforms
- Register Faces — enrol the captured image IDs
- Verify Face Authen — authenticate with a fresh capture