Android SDK
Integrate the TrustPlatform Android SDK into your Android app
This page covers the Android setup. For what the SDK does and how it fits into your integration, see the Mobile SDK overview.
Requirements
| Requirement | Minimum version |
|---|---|
| Android API | 28 (Android 9.0) |
compileSdk | 37.1 |
| Android Gradle Plugin | 9.1.0 |
| Kotlin | 2.x |
These are the Trust Platform SDK's requirements. If you add native document verification, the DocIDV SDK's requirements also apply. If you add native device signals, the Fingerprint Pro Android SDK's requirements also apply.
Steps that open an external eID provider also need an Android System WebView that supports both WebViewFeature.WEB_MESSAGE_LISTENER and WebViewFeature.DOCUMENT_START_SCRIPT. Support depends on the WebView build installed on the device rather than on its version number, so the SDK checks both at runtime and your app needs no version check of its own. On a device whose WebView lacks either feature the session still runs, but the provider window cannot open, so the eID step cannot be completed. To check the WebView on a device, run adb shell dumpsys webviewupdate. See Verifying eID (v2).
Installation
1. Add the Maven repository
Add the following to your settings.gradle.kts:
dependencyResolutionManagement {
repositories {
maven { url = uri("https://raw.githubusercontent.com/idnow/idnow-android-sdk/main") }
}
}
2. Add the dependency
Use the BOM to keep module versions in sync:
// build.gradle.kts
dependencies {
implementation(platform("io.idnow.trustplatform:bom:<version>"))
implementation("io.idnow.trustplatform:core")
}
Register for Events
Call TrustPlatformSession.registerForResult in onCreate(), before the activity reaches onStart(). It takes one event handler and returns a session object that you use to launch and stop the SDK:
class MainActivity : ComponentActivity() {
private lateinit var session: TrustPlatformLauncher
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
session = TrustPlatformSession.registerForResult(this) { event ->
when (event) {
is TrustPlatformEvent.Progress -> { /* See Follow progress below. */ }
is TrustPlatformEvent.Completed -> {
// The flow completed. Query your backend for the outcome.
// See https://docs.eu.platform.idnow.io/docs/integration/get-session-results
}
is TrustPlatformEvent.Aborted -> { /* The session was aborted on the server. */ }
is TrustPlatformEvent.Dismissed -> { /* The SDK closed before the flow ended. The session keeps running. */ }
is TrustPlatformEvent.Failed -> { /* event.error contains details */ }
}
}
}
}
The handler runs on the main thread.
Configure the SDK
Pass a TrustPlatformEnvironment when you launch a session.
| Environment | Description |
|---|---|
TrustPlatformEnvironment.Production | The production environment |
TrustPlatformEnvironment.Sandbox | The sandbox environment for development and testing (default) |
Configure Permissions
The SDK declares INTERNET and ACCESS_NETWORK_STATE itself; both are merged into your app automatically. Check which device capabilities your flow needs, then add the matching permissions to your AndroidManifest.xml and request them at runtime before you launch a session:
| Permission | Required for |
|---|---|
android.permission.CAMERA | Document and biometric capture |
android.permission.RECORD_AUDIO | Video-based verification steps, such as agent video calls |
<uses-permission android:name="android.permission.CAMERA" />
<!-- Only if your flow includes video-based verification steps -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
If the app has not been granted a permission, the SDK denies the matching camera or microphone request from the flow, and the step cannot capture.
NFC permissions for native document verification come with the DocIDV module. See native document verification.
Returning from an EUDI wallet
Flows that use the EUDI Wallet step hand the user to a separate wallet app to present their
credentials, and Android reopens your app afterwards. Nothing is required on your side: the SDK
declares the derived return scheme (<applicationId>.idnow) in its own manifest, on a dedicated
trampoline activity, and the manifest merger fills in your application id. Do not declare it
yourself — with two matching activities in the same app, Android would ask the user to disambiguate.
The flow activity itself stays unexported.
Launch a Session
Create a session via the API, then launch the SDK with the session token:
session.launch(
TrustPlatformConfig(
token = token,
environment = TrustPlatformEnvironment.Production,
)
)
To close the SDK from your app, call session.stop(). See Close the SDK early.
Handle Events
The event handler receives progress while the flow runs, and then how the flow ended.
| Event | When it occurs |
|---|---|
Progress(progress: StepProgress) | The current step reports what it is waiting for. See Follow progress |
Completed | The flow finished (the outcome might be accepted or rejected) |
Aborted | The session was aborted on the server, for example because the user quit from the flow's own quit dialog |
Dismissed | The SDK closed before the flow ended, for example because the user pressed the back button. The session keeps running |
Failed(error: TrustPlatformError) | The flow failed; error describes why |
You receive any number of Progress events, then at most one terminal event: Completed, Aborted, Dismissed or Failed. Nothing follows it. If you close the SDK yourself with stop(), no terminal event is sent.
Completed only signals that the flow finished. To retrieve the actual outcome, query the Get session results API endpoint using the sessionId you received when creating the session. See Interpret session results for how to act on it. If the user returns after Aborted, start a new session.
TrustPlatformEvent is a closed set. event.error.message contains a machine-readable description suitable for logging. To display a localised, user-facing message, call event.error.errorDescription(context) instead. See Handle Errors for the error cases and their machine-readable codes.
is TrustPlatformEvent.Failed -> {
Log.e(TAG, event.error.message ?: "Unknown error")
showError(event.error.errorDescription(context))
}
Follow progress
Progress events tell your app what the current step is waiting for. Use them to track where the user is in the flow, or to react, for example by closing the SDK when a manual review starts.
session = TrustPlatformSession.registerForResult(this) { event ->
when (event) {
is TrustPlatformEvent.Progress -> {
analytics.track("verification_progress", mapOf("progress" to event.progress.name))
if (event.progress == StepProgress.InManualReview) {
// Optional: close the SDK here if the user has nothing left to do while the review runs.
session.stop()
}
}
// ... the other events
}
}
StepProgress is an open set: more values will follow, so treat one you don't recognise as InProgress. The values, and which steps report them, are described in Track step progress.
Progress is reported when the value changes, and short-lived values can be skipped. Progress can also be lost if Android recreates your activity or ends your app's process while the SDK is on screen. If you must not miss a change, follow the session with step events on your backend.
Close the SDK early
Call session.stop() to close the SDK while the flow runs. If you call it while the progress is InManualReview, the review carries on. stop() doesn't end the session and sends no event. Android has no equivalent of an await, so do anything your app needs after closing the SDK right after the stop() call, not in an event branch.
Run again
To open the SDK again for the same session, call launch again. This starts a new run on the device, with no memory of the previous one, and the session carries on from where it is. If the current step is already waiting when the run starts, you receive its progress value straight away, for example Progress(StepProgress.InManualReview) right after opening. Don't run two SDK instances for the same session at the same time: the second one is treated as a takeover from another device.
Handle Errors
A Failed event carries a TrustPlatformError when a technical failure prevents the flow from running or completing.
| Case | When it occurs |
|---|---|
InternalError | An unexpected SDK-internal failure |
NetworkFailure | No connection or a request failed |
SessionExpired | The session timed out on the server |
InvalidToken | The session token is not valid for an SDK session |
FingerprintEventRejected | The server rejected the collected device signals as forged or stale. Terminal — starting a new session is the only recovery |
FlowError | The flow reached a terminal state other than completed, aborted or expired |
NativeHandlerFailure | A native handler reported a non-recoverable failure |
TrustPlatformError is an open set: future SDK versions may add cases, so treat one you don't recognise as you would InternalError.
Machine-readable error codes
Every error carries a stable code your app or backend can match on. When the failure was classified from an HTTP request, the error also carries a requestId identifying that request — hand it to IDnow support to correlate the failure with server-side logs.
| Code | Carried by | When it occurs |
|---|---|---|
TOKEN_EXPIRED | SessionExpired, NativeHandlerFailure | The session or native token expired (HTTP 401), or the flow reached its expiry while the SDK was polling |
INVALID_TOKEN | InvalidToken, NativeHandlerFailure | The token is not valid for this session (HTTP 401/403) |
UNDELIVERABLE | NativeHandlerFailure | A device-signals report could not be delivered after exhausting its retries |
INTERNAL_ERROR | InternalError, NativeHandlerFailure | An unexpected SDK-internal failure |
NETWORK_FAILURE | NetworkFailure | A network call failed (I/O or timeout) |
FLOW_ERROR | FlowError | The flow reached a terminal state other than completed, aborted or expired |
FINGERPRINT_EVENT_NOT_FOUND | FingerprintEventRejected | The server rejected the collected device signals as forged or stale (HTTP 412) |
TERMINAL_STATE | — | The flow is already terminal (HTTP 409); the SDK polls for the final status instead of failing |
FINGERPRINT_TIMEOUT | failure reports to the platform | Device-signals collection timed out; the platform marks the step failed |
FINGERPRINT_NETWORK | failure reports to the platform | Device-signals collection failed on the network; the platform marks the step failed |
FINGERPRINT_UNKNOWN | failure reports to the platform | Device-signals collection failed for an unknown reason; the platform marks the step failed |
FINGERPRINT_INVALID_RESPONSE | failure reports to the platform | Device-signals collection returned an unusable response; the platform marks the step failed |
The FINGERPRINT_* codes are sent to the platform as the step's failure reason — they appear in platform logs and step results, not in your event handler. Codes a newer server introduces pass through unmodified, so match unknown codes generically rather than exhaustively.
Native document verification (optional)
The trustplatform-docidv module runs document capture, and NFC chip reading where the flow uses it, as native screens instead of in the webview. It uses IDnow's DocIDV SDK, which the module brings in as a dependency; Maven resolves the matching version for you. Sessions, outcomes and data blocks are the same either way. See the Mobile SDK overview.
The DocIDV SDK's requirements apply when you add this module. For details specific to the DocIDV SDK, see the standalone DocIDV SDK documentation.
Add the Dependency
// build.gradle.kts
dependencies {
implementation(platform("io.idnow.trustplatform:bom:<version>"))
implementation("io.idnow.trustplatform:core")
implementation("io.idnow.trustplatform:docidv")
}
NFC permissions are included automatically via manifest merging from the DocIDV module's dependencies. No additional NFC entries are required in your manifest.
App name collision
Android resolves string resources per configuration across your app and all of its libraries, so a dependency that declares a localised value under the same key overrides yours on those locales. With a generic key such as app_name, the launcher then shows the dependency's name instead of your app's.
Do:
- Use an app-prefixed key for your app's name, for example
myapp_app_nameinstead ofapp_name. - Define it in the default
values/folder and reference it fromandroid:labelon<application>. - Add
tools:replace="android:label"to<application>and declare thetoolsnamespace on<manifest>. The manifest merger requires it whenever a dependency also setsandroid:label; without it the merge fails instead of keeping your value.
Do not:
- Reuse a generic key such as
app_namefor your app's name. - Add
values-<locale>/strings.xmloverrides to win the collision. They tie your app to the locales the dependency ships today and break again when it adds another one.
<!-- res/values/strings.xml -->
<string name="myapp_app_name">My App</string>
<!-- AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:label="@string/myapp_app_name"
tools:replace="android:label">
<!-- ... -->
</application>
</manifest>
NFC chip reading
NFC chip reading needs an additional dependency that is not available on Maven. Follow Integrate the NFC dependency in the DocIDV SDK documentation. NFC results are processed by the Verifying ID document (v3) step.
Packaging Configuration
trustplatform-docidv depends on BouncyCastle, which ships duplicate META-INF/LICENSE.md files across its JARs. Add the following packaging block to your android {} configuration to prevent a build error:
// build.gradle.kts
android {
packaging {
resources {
pickFirsts += setOf(
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md",
)
}
}
}
How It Works
When you add trustplatform-docidv to your dependencies, the SDK discovers the DocIDV handler automatically at runtime via ServiceLoader — no registration call is required. If the dependency is absent, the SDK runs the document step in the webview instead.
Native device signals (optional)
The trustplatform-fingerprint module executes Device signals (v2) steps natively using the Fingerprint Pro Android SDK, instead of running the step in the webview. It brings the Fingerprint Pro SDK in as a dependency. Sessions, outcomes and data blocks are the same either way — the module only changes where the collection runs. See the Mobile SDK overview.
The module adds roughly 3.6 MB. Without it, Device signals (v2) steps run in the webview, at no added cost.
Add the Dependency
// build.gradle.kts
repositories {
maven {
url = uri("https://maven.fpregistry.io/releases")
content { includeGroupByRegex("com\\.fingerprint.*") }
}
}
dependencies {
implementation(platform("io.idnow.trustplatform:bom:<version>"))
implementation("io.idnow.trustplatform:core")
implementation("io.idnow.trustplatform:fingerprint")
}
The maven.fpregistry.io repository is required: it is the only source of the Fingerprint Pro Android SDK.
How It Works
When you add trustplatform-fingerprint to your dependencies, the SDK discovers the handler automatically at runtime via ServiceLoader — no registration call is required. If the dependency is absent, the SDK runs the step in the webview instead.
When a session reaches a Device signals (v2) step, the SDK collects one Fingerprint Pro event with the credentials the step carries and reports the outcome to the platform — the webview is never loaded for the step. Step routing is identical to the webview: the SDK reports only the event identifiers, and the platform resolves the verdict. Native step execution requires a Player version that serves device-signals directives to mobile SDK sessions; with an older Player the step runs in the webview.
If collection fails (no network, blocked request, timeout), the SDK reports the failure to the platform and the step fails: the session ends with TrustPlatformEvent.Failed carrying a TrustPlatformError.FlowError — it never reports a fabricated success, and no route is taken. If the report itself cannot be delivered after retries, the session ends with TrustPlatformEvent.Failed carrying a TrustPlatformError.NativeHandlerFailure whose code identifies the reason — see Machine-readable error codes.
Passive device fingerprinting (optional)
The trustplatform-fingerprint module also lets sessions of a qualifying organisation collect the DeviceContext data block with Fingerprint Pro instead of the SDK's native collector. Qualification is organisation-level and automatic — Fingerprint Pro credentials in the session environment and Protect enabled — so your integration needs no configuration beyond adding the module. See Passive device fingerprinting for the behaviour and the detections it adds.
No separate setup: the same Add the Dependency step as above enables both capabilities. When you add the module, the SDK collects one Fingerprint Pro event when the session starts and sends only its event id; the IDnow platform builds the device context. If the module is absent, the organisation does not qualify, or collection fails (no network, blocked request, timeout), the session still starts on the native collector.