> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/merchant-tokenization/sdk-integration/integration/android.md). Agents can also search and read this documentation through its [MCP server](https://docs.payments.thalescloud.io/~gitbook/mcp).

# Android

Use this guide to integrate the **Thales SDK** into an Android merchant application.

### Delivery package <a href="#delivery-packages" id="delivery-packages"></a>

The SDK delivery package includes:

| Name                                            | Description                                                 |
| ----------------------------------------------- | ----------------------------------------------------------- |
| tmgsdk-debug-`<version>`-`<release_date>`.aar   | Debug AAR for Thales SDK.                                   |
| tmgsdk-release-`<version>`-`<release_date>`.aar | Release AAR for Thales SDK.                                 |
| demo                                            | Sample project that shows how to integrate and use the SDK. |
| javadoc                                         | SDK API documentation.                                      |

### Dependencies <a href="#dependencies" id="dependencies"></a>

<table><thead><tr><th width="100">Dependency Name</th><th width="100">Version</th><th>Description</th></tr></thead><tbody><tr><td>JNA</td><td>5.5.0</td><td>This library is used to access the native libraries shipped with Thales SDK.</td></tr><tr><td>AndroidX Biometric</td><td>1.1.0</td><td>This library is used for biometric authentication on Android devices.</td></tr></tbody></table>

{% hint style="warning" %}
Since SDK v2.0.0, OkHttp is no longer required.
{% endhint %}

### Integrate the SDK <a href="#application-integration" id="application-integration"></a>

1. Create a folder called `libs` under the project directory.

<figure><img src="https://1873847743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9XBN1F9dv7Dl1ggilGWC%2Fuploads%2FgMYP2MS3ngOcxoihi90B%2F%7BBA31E7F3-9182-412E-99F1-4D271E111E29%7D.png?alt=media&amp;token=a53d7fe7-eaf5-4c31-948a-48a5bc89904a" alt=""><figcaption><p>Example <code>libs</code> folder containing the SDK AAR.</p></figcaption></figure>

2. Copy `tmgsdk-<variant>-<version>-<release_date>.aar` into the `libs` folder.

   `variant` is `debug` or `release`.
3. Open the `app/build.gradle` file and add the following dependencies:

```java
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'net.java.dev.jna:jna:5.5.0@aar'
implementation fileTree(dir: 'libs', include: ['*.aar'])
```

### Configure the SDK <a href="#sdk-configuration" id="sdk-configuration"></a>

{% hint style="warning" %}

* Since SDK v2.0.0, the application is no longer required to provide the certificate PIN value.
* Since SDK v3.0.0, the SDK no longer supports Android Keyguard.
  {% endhint %}

Configure Thales SDK before calling any SDK API.

Build a `TMGClientConfiguration` with the required parameters:

* Application context
* Server URL
* Server certificate
* Key identifier

#### 1. Create a `TMGClientConfiguration`

Get the server URL, server certificate, and key identifier during onboarding.

```java
Activity activity;
String serverUrl;
byte[] serverCertificate;
String keyIdentifier;
TMGClientConfiguration tmgClientConfiguration = new TMGClientConfiguration(activity, 
                                                                           serverUrl, 
                                                                           serverCertificate, 
                                                                           keyIdentifier);
```

#### 2. Check biometric support

Check whether the device supports biometric authentication.

```java
int biometricSupport = DeviceAuthenticationChecker.getBiometricsSupport(activity);
if (biometricSupport == BiometricsSupport.SUPPORTED) {
    // The current device supports biometrics.
}
```

#### 3. Create a `VisaCTFHelper`

Create the helper to start device binding and authenticate transactions for Visa CTF and DAF.

```java
public void initVisaCTFHelper(@NonNull TMGClientConfiguration tmgClientConfiguration) {
    try {
        VisaCTFHelper visaCTFHelper = TMGClient.getInstance().createVisaCTFHelper(tmgClientConfiguration);
    } catch (TMGClientException e) {
        // Handle error.
    }
}
```

#### 4. Create a `MastercardTAFHelper`

Create the helper to start device binding and authenticate transactions for Mastercard TAF.

```java
public void initMastercardTAFHelper(@NonNull TMGClientConfiguration tmgClientConfiguration) {
   try {
       MastercardTAFHelper mastercardTAFHelper = TMGClient.getInstance().createMastercardTAFHelper(tmgClientConfiguration);
   } catch (TMGClientException e) {
       // Handle error.
   }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/merchant-tokenization/sdk-integration/integration/android.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
