Skip to content

Installation

Using Zip files

  1. Create a new Android project (or use an existing one).
  2. Import all provided .aar libraries into the app/libs directory:

    The following libraries must be included:

    genuine-ds-X.Y.Z.aar
    platform-common-definitions-X.Y.Z.aar
    platform-common-image-manipulation-X.Y.Z.aar
    platform-common-utils-X.Y.Z.aar
    platform-nativeds-X.Y.Z.aar
    sdk-camera-X.Y.Z.aar
    sdk-core-X.Y.Z.aar
    sdk-nfc-X.Y.Z.aar
    
  3. Add the SDK libraries to the app build.gradle dependencies:

    implementation(files("libs/genuine-ds-X.Y.Z.aar"))
    implementation(files("libs/platform-common-definitions-X.Y.Z.aar"))
    implementation(files("libs/platform-common-image-manipulation-X.Y.Z.aar"))
    implementation(files("libs/platform-common-utils-X.Y.Z.aar"))
    implementation(files("libs/platform-nativeds-X.Y.Z.aar"))
    implementation(files("libs/sdk-camera-X.Y.Z.aar"))
    implementation(files("libs/sdk-core-X.Y.Z.aar"))
    implementation(files("libs/sdk-nfc-X.Y.Z.aar"))
    
  4. Add the required Jetpack Compose dependencies.

    The SDK UI is built using Jetpack Compose. Since local .aar integrations do not automatically expose all transitive dependency metadata, the host application must explicitly include the required Compose dependencies:

    implementation(platform("androidx.compose:compose-bom:<version>"))
    implementation("androidx.compose.material3:material3")
    implementation("androidx.activity:activity-compose:<version>")
    implementation("androidx.lifecycle:lifecycle-runtime-compose:<version>")
    implementation("androidx.lifecycle:lifecycle-viewmodel-compose:<version>")
    
  5. Add the required external dependencies:

    implementation("org.jmrtd:jmrtd:<version>")
    implementation("net.sf.scuba:scuba-sc-android:<version>")
    implementation("org.bouncycastle:bcprov-jdk18on:<version>")
    implementation("org.bouncycastle:bcpkix-jdk18on:<version>")
    implementation("org.bouncycastle:bcutil-jdk18on:<version>")
    implementation("edu.ucar:jj2000:<version>")
    implementation("com.google.mediapipe:tasks-vision:<version>")
    implementation("io.coil-kt:coil-compose:<version>")
    implementation("io.coil-kt:coil-gif:<version>")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:<version>")
    implementation("org.jetbrains.kotlin:kotlin-reflect:<version>")
    
  6. Use tested dependency versions

    Dependency Compatible version
    JMRTD 0.8.8
    SCUBA (scuba-sc-android) 0.0.27
    Bouncy Castle (jdk18on) 1.86
    JJ2000 5.2
    Compose BOM 2025.06.00
    Activity Compose 1.10.1
    Lifecycle 2.8.7
    Media Pipe 0.10.32
    Coil Compose 2.6.0
    Kotlinx Serialization JSON 1.6.3
    Kotlin Reflect 1.9.25

    Newer versions may work, but compatibility should be validated by the integrator. This is especially important for Jetpack Compose dependencies, where incompatible module versions may lead to runtime errors such as NoSuchMethodError or NoClassDefFoundError.

  7. Exclude the duplicated Bouncy Castle manifest.

    Several Bouncy Castle libraries ship the same META-INF/versions/9/OSGI-INF/MANIFEST.MF file, which makes the build fail with a duplicate file error. Exclude it in the android block of the app build.gradle:

    packaging {
        resources.excludes.add("META-INF/versions/9/OSGI-INF/MANIFEST.MF")
        resources.pickFirsts.add("META-INF/LICENSE.md")
    }
    
  8. Sync the project with Gradle and build the application.

    android:largeHeap="true" is strongly recommended in the application manifest to improve memory availability during image processing flows.

Third party libraries

  • JMRTD (main page). It is an open source Java implementation of the Machine Readable Travel Document (MRTD) standards as specified by the International Civil Aviation Organization (ICAO).
  • SCUBA (main page). SCUBA is a Java based framework for programming smart card aware host applications.
  • Bouncy Castle (main page). Cryptography libraries, used to verify the certificates and the signatures of the document.
  • JJ2000 (main page). JPEG 2000 decoder, used to decode the images stored in the chip.
  • Coil (main page). Used for image loading.

Enable NFC reading

The SDK declares the NFC permission in its own manifest, so you do not need to add it. If you want Google Play to offer your app only to devices with NFC, declare it as a required feature. See Specifications for details.

<uses-feature android:name="android.hardware.nfc" android:required="true" />

No other manifest entry, such as an intent filter, is needed: the SDK activity reads the chip while it is on screen.

Prepare the configuration

  • Provide an NfcReadConfiguration instance (you can build it in code or load it from a JSON).
  • List in keys the data fields you want in the result. If you set none, the result carries no text field, only the photos.
  • If your app already knows the document data (for example, from a previous document capture), set it as prefill to skip the form.

Minimal code usage

Import the SDK, create the configuration (programmatically or from JSON), and start the flow:

import android.util.Log
import androidx.activity.ComponentActivity
import com.veridas.sdk.nfc.entrypoint.NfcRead
import com.veridas.sdk.nfc.entrypoint.NfcReadEventsListener
import com.veridas.sdk.nfc.entrypoint.NfcReadListener
import com.veridas.sdk.nfc.entrypoint.NfcReadResult
import com.veridas.sdk.nfc.error.NfcReadError
import com.veridas.sdk.nfc.event.NfcReadEvent

class NfcIntegratorActivity :
    ComponentActivity(),
    NfcReadListener,
    NfcReadEventsListener
{
    private companion object {
        private val TAG = NfcIntegratorActivity::class.simpleName
    }

    fun startNfcRead() {
        NfcRead.start(
            listener = this,
            configuration = getConfigurationFromAsset("nfcRead.json"),
            context = this
        )
        NfcRead.setEventsListener(this)
    }

    // NfcReadListener
    override fun onNfcReadResults(results: NfcReadResult) {
        Log.i(TAG, "NFC SDK -- onNfcReadResults $results")
    }

    override fun onNfcReadStarted() {
        Log.i(TAG, "NFC SDK -- Started")
    }

    override fun onNfcReadFinished(error: NfcReadError?) {
        Log.i(TAG, "NFC SDK -- onNfcReadFinished $error")
    }

    // NfcReadEventsListener
    override fun onNfcReadEvent(event: NfcReadEvent) {
        Log.i(TAG, "NFC SDK -- onNfcReadEvent $event")
    }
}

Example helper for loading JSON configs (shared by all SDKs):

import com.veridas.sdk.nfc.configuration.NfcReadConfiguration
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json

@OptIn(ExperimentalSerializationApi::class)
private val json = Json {
    ignoreUnknownKeys = true
    explicitNulls = false
}

fun getConfigurationFromAsset(fileName: String): NfcReadConfiguration {
    val jsonString = applicationContext
        .assets
        .open(fileName)
        .bufferedReader()
        .use { it.readText() }

    return json.decodeFromString<NfcReadConfiguration>(jsonString)
}

Example building the configuration in code:

import com.veridas.sdk.nfc.configuration.NfcReadConfiguration
import com.veridas.sdk.nfc.configuration.NfcSetup

fun startNfcRead() {
    val config = NfcReadConfiguration(
        setup = NfcSetup(
            language = "en",
            maxRetries = 3,
            keys = listOf("DG1_NAME", "DG1_SURNAME", "DG1_DOC_NUMBER")
        )
    )
    NfcRead.start(listener = this, configuration = config, context = this)
    NfcRead.setEventsListener(this)
}

NfcReadListener covers onNfcReadResults, onNfcReadStarted and onNfcReadFinished, while NfcReadEventsListener can be implemented optionally to receive tracking events through onNfcReadEvent. Details are in the API section.

Use a device with NFC

NFC is not available on the Android Emulator or on devices without an NFC reader. Use a physical device with NFC to run the app that integrates the SDK.