> 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).

# 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="/files/5BAxNwfvAvYBLjGAniaX" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
