> 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/classic-push-provisioning/ja/gaido/sdk-she-ding/android.md).

# Android

Push Provisioning SDK は、Google Pay と Samsung Pay 用にカードをトークン化するために使用されます。この SDK は、Google Pay および Samsung Pay の SDK との通信を処理します。また、イシュアアプリケーション向けのトークン化フローを簡素化します。

このセクションは、Push Provisioning SDK を自分のアプリケーションに統合したい Android イシュアアプリケーション開発者向けです。

### 利用可能なサービス <a href="#available-services" id="available-services"></a>

Thales Push Provisioning SDK は、以下のサービスを提供します。

* イシュアアプリケーションを Push Provisioning SDK API と統合できるようにします。たとえば `isCardDigitized` および `addCard` （Google Pay と Samsung Pay）。
* Google Pay と Samsung Pay の SDK について理解する必要性を減らします。
* 既存のプロジェクトで Push Provisioning SDK サービスを再利用します。
* FPAN を Google Pay または Samsung Pay に登録します。
* TSH サーバー API にアクセスします。

### 前提条件 <a href="#prerequisites" id="prerequisites"></a>

* Java バージョン: 11
* Android Studio バージョン: Chipmunk 以降。
* Google Play サービスを搭載したデバイス（Google Pay 用）。

> <i class="fa-info-circle">:info-circle:</i>
>
> Google Pay の全機能を利用するには、モバイル端末で実行することを推奨します。

### イシュアアプリとの統合 <a href="#integrating-with-issuer-app" id="integrating-with-issuer-app"></a>

* 次の名前のフォルダーを作成します `libs` をモジュール（通常は 'app'）ディレクトリ内に作成します。以下の図に示すとおりです。

<figure><img src="https://3356216997-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC22AqJs7fn1cZC7pAaOE%2Fuploads%2FaVZ5xunluNKEoqgRwQ63%2FDev-Guide_SDK-conf_01.png?alt=media&amp;token=d21c8dad-b05a-421f-9153-1227e3e0c7a1" alt=""><figcaption></figcaption></figure>

* Push Provisioning SDK の AAR ファイルを `libs` フォルダーにコピーします。
* Push Provisioning SDK v1.12.2 以降、Samsung Pay SDK の JAR ファイルを `libs` フォルダーにコピーします。
* Push Provisioning SDK v2.0.0 以降、Google Pay SDK の AAR ファイルを `libs` フォルダーにコピーします。
* アプリの `build.gradle` または `build.gradle.kts` を開き、以下の依存関係を追加します。

{% tabs %}
{% tab title="Groovy" %}

```groovy
android {
  defaultConfig {
    ndk {
      abiFilters 'arm64-v8a', 'x86_64', 'armeabi-v7a', 'x86'
    }
  }
  buildTypes {
        debug {
            // Samsung Pay 用
            manifestPlaceholders = [DEBUG_MODE: 'Y', SPAY_API_LEVEL: 2.22]
        }
        release {
            // Samsung Pay 用
            manifestPlaceholders = [DEBUG_MODE: 'N' , SPAY_API_LEVEL: 2.22]
        }
    }
}

dependencies {
    debugImplementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' // debug にはロガーが含まれます
    releaseImplementation 'com.squareup.okhttp3:okhttp:4.9.1'
    implementation "com.google.android.gms:play-services-base:18.5.0"
    implementation "com.google.android.gms:play-services-basement:18.5.0"
    implementation files('libs/tpcsdk.aar') // 最新の Push Provisioning SDK ファイル名を使用してください 
    implementation files('libs/samsungpay_2.22.00.jar') // SDK v1.12.2 以降
    implementation files('libs/play-services-tapandpay-18.7.0.aar') // SDK v2.0.0 以降
    implementation 'net.java.dev.jna:jna:5.17.0@aar'
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
android {
  defaultConfig {
    ndk {
      abiFilters += listOf("arm64-v8a", "x86_64", "armeabi-v7a", "x86")
    }
  }
}

dependencies {
    debugImplementation ("com.squareup.okhttp3:logging-interceptor:4.9.1") // debug にはロガーが含まれます
    releaseImplementation ("com.squareup.okhttp3:okhttp:4.9.1")
    implementation ("com.google.android.gms:play-services-base:18.2.0")
    implementation files('libs/samsungpay_2.22.00.jar') // SDK v1.12.2 以降
    implementation files('libs/play-services-tapandpay-18.7.0.aar') // SDK v2.0.0 以降
    implementation (files("libs/tpcsdk.aar")) // 最新の Push Provisioning SDK ファイル名を使用してください 
    implementation ("net.java.dev.jna:jna:5.17.0@aar")
}
```

{% endtab %}
{% endtabs %}

> <i class="fa-info-circle">:info-circle:</i>
>
> #### 注記 <a href="#note" id="note"></a>
>
> * Push Provisioning SDK V1.7.0 以降、JNA ライブラリは依存関係として使用されます。他のバージョンが Push Provisioning SDK で動作することは保証されないため、JNA V5.5.0 の使用を推奨します。
> * Push Provisioning SDK V1.12.0 以降、16 KB ページサイズをサポートするために JNA V5.17.0 の使用が必須です。

* Gradle ビルドにファイルツリー依存関係をインポートするには、アプリの `build.gradle` または `build.gradle.kts` を開き、次の依存関係を追加します。

{% tabs %}
{% tab title="Groovy" %}

```groovy
dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"] )
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
dependencies {
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
}
```

{% endtab %}
{% endtabs %}

* サンプルアプリと Java ドキュメントを参照して、Push Provisioning SDK API の使用方法を確認してください。

> <i class="fa-exclamation-circle">:exclamation-circle:</i>
>
> #### 16 KB ページサイズのサポート <a href="#supporting-16-kb-page-sizesbr" id="supporting-16-kb-page-sizesbr"></a>
>
> 2025 年 11 月 1 日以降、Google Play に提出される新規開発アプリおよび既存アプリの更新のうち、Android 15 以降のデバイス向けのものは、16 KB ページサイズをサポートする必要があります。このサポートは Push Provisioning SDK V1.12.0 以降で利用できます。
>
> 16 KB ページサイズをサポートする APK をビルドする場合:
>
> * Push Provisioning SDK V1.12.0 以降にアップグレードします。
> * JNA 依存関係を 5.17.0 以降にアップグレードします。JNA 5.17.0 では、必要な Android Gradle Plugin (AGP) のバージョンは 8.0.2 以降です。8.0.2 より前の AGP を使用すると、コンパイルの問題が発生する可能性があります。
> * AGP のバージョンが 8.5.1 以降の場合、アプリは自動的に 16 KB ページサイズに整合されます。8.5.1 より前の場合は、 [レガシー パッケージング オプション](https://developer.android.com/guide/practices/page-sizes#agp_version_85_or_lower) を `build.gradle` ファイルに設定します。

### 構成 <a href="#configuration" id="configuration"></a>

次のスニペットを使用して、モバイルアプリケーションで Push Provisioning SDK を構成します。

> <i class="fa-info-circle">:info-circle:</i>
>
> #### 注記 <a href="#note-1" id="note-1"></a>
>
> Push Provisioning SDK V1.9.0 以降、アプリケーションはアプリケーション `Context` の代わりに `Activity` Google Pay と Samsung Pay 用に Push Provisioning SDK を構成する際には、アプリケーションの `Activity` は、新しい API でのみ必要です、 `addCard(Activity activity, CardInfo cardInfo, TPCSDKListener<T> listener)`は、Google Pay のプッシュ プロビジョニング用です。

{% tabs %}
{% tab title="Java" %}

```java
protected static final int HTTP_TIMEOUT = 60;

protected CountDownLatch mCountDownLatch;

protected void awaitCountDownLatch() {
    try {
        mCountDownLatch.await(HTTP_TIMEOUT, TimeUnit.SECONDS);
    } catch (Exception e) { // 無視します。
    }
}

protected void resetCountDownLatch() {
    mCountDownLatch = new CountDownLatch(1);
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    // スキーム プッシュ プロビジョニング用に SDK を構成します
    // Push Provisioning SDK V2.0.0 以降では、OEM Wallet プロビジョニングを実行する場合にのみ OEMPayType を設定します。それ以外では OEM タイプは未設定のままにします。
    Config schemeConfig = new Config();
    schemeConfig.setIssuerId("ISSUERID");
    schemeConfig.setUrl("URL"); // 対応する URL
    // Push Provisioning SDK V1.9.0 以降、Application は `Context` を設定できます
    // Push Provisioning SDK の構成時に `Activity` の代わりに
    // スキーム プロビジョニング用に
    schemeConfig.setContext(getApplicationContext());
    configSdkForScheme(schemeConfig);
    
    // OEM プッシュ プロビジョニング用に SDK を構成します
    Config oemConfig = new Config();
    oemConfig.setIssuerId("ISSUERID");
    oemConfig.setUrl("URL"); // 対応する URL
    
    // リストは適宜更新できます。たとえば、OEMPayType は 1 種類だけで十分な場合があります。
    List<OEMPayType> oemPayTypes = Arrays.asList(
        // Push Provisioning SDK V2.0.0 以降、OEMPayType.NONE はサポートされなくなりました
        OEMPayType.GOOGLE_PAY,
        OEMPayType.SAMSUNG_PAY,
        OEMPayType.HUAWEI_PAY);

    for (OEMPayType oemPayType:oemPayTypes) {
        if (oemPayType == OEMPayType.SAMSUNG_PAY) {
            oemConfig.setContext(getApplicationContext());
            oemConfig.setServiceId("SERVICEID");
            oemConfig.setVisaClientAppId("VisaClientAppID");
        } else if (oemPayType == OEMPayType.HUAWEI_PAY) {
            String callbackUrl = "tpcsdk://com.thalesgroup.tpc.demo/tokenRequestorsPage";
            oemConfig.setCallbackUrl(callbackUrl);
            oemConfig.setActivity(getActivity());
        } else if (oemPayType == OEMPayType.GOOGLE_PAY) {
            // Push Provisioning SDK V1.9.0 以降、Google Pay 用の Push Provisioning SDK 構成時に、Application は `Context` を `Activity` の代わりに設定できます
            oemConfig.setContext(getApplicationContext());
        }
        configSdk(oemPayType, oemConfig);
    }
}

public void configSdkForScheme(Config configs) throws InterruptedException {
    // Push Provisioning SDK V2.0.0 以降、スキーム プッシュ プロビジョニングでは OEMPayType を設定しないでください
    resetCountDownLatch();
    TPCManager.getInstance().config(configs, new TPCSDKListener<Boolean>() {
        @Override
        public void onStart() {
        }

        @Override
        public void onSuccess(TPCResult<Boolean> result) {
            Log.d("CONFIG_SDK", "Scheme configuration successful...");
            mCountDownLatch.countDown();
        }

        @Override
        public void onError(TPCSDKException exception) {
            Log.e("CONFIG_SDK", "Scheme configuration failed with error: " + exception.getMessage());
            mCountDownLatch.countDown();
        }
    });
    awaitCountDownLatch();
}

public void configSdk(OEMPayType oemPayType, Config configs) throws InterruptedException {
    configs.setOemPayType(oemPayType);
    resetCountDownLatch();
    TPCManager.getInstance().config(configs, new TPCSDKListener<Boolean>() {
        @Override
        public void onStart() {
        }

        @Override
        public void onSuccess(TPCResult<Boolean> result) {
            Log.d("CONFIG_SDK", "Configuration successful..." + oemPayType.getOemType());
            mCountDownLatch.countDown();
        }

        @Override
        public void onError(TPCSDKException exception) {
            Log.e("CONFIG_SDK", "Configuration setup failed with error: " + exception.getMessage());
            mCountDownLatch.countDown();
        }
    });
    awaitCountDownLatch();
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
class MainViewModel : ViewModel() {
    fun configureMultipleOEM(activity: Activity){
        viewModelScope.launch {
            // スキーム プッシュ プロビジョニング用に SDK を構成します
            // Push Provisioning SDK V2.0.0 以降では、OEM Wallet プロビジョニングを実行する場合にのみ OEMPayType を設定します。それ以外では OEM タイプは未設定のままにします。
            val schemeConfig = Config()
            schemeConfig.issuerId = "ISSUERID"
            schemeConfig.url = "URL" // 対応する URL
            // Push Provisioning SDK V1.9.0 以降、Application は `Context` を設定できます
            // Push Provisioning SDK の構成時に `Activity` の代わりに
            // スキーム プロビジョニング用に
            schemeConfig.context = applicationContext

            configSdkForScheme(schemeConfig).collect {
                println(it)
            }

            // OEM プッシュ プロビジョニング用に SDK を構成します
            val oemConfig = Config()
            oemConfig.issuerId = "ISSUERID"
            oemConfig.url = "URL" // 対応する URL

            // リストは適宜更新できます。たとえば、OEMPayType は 1 種類だけで十分な場合があります。
            val oemPayTypes: List<OEMPayType> = listOf(
                // Push Provisioning SDK V2.0.0 以降、OEMPayType.NONE はサポートされなくなりました
                OEMPayType.GOOGLE_PAY,
                OEMPayType.SAMSUNG_PAY,
                OEMPayType.HUAWEI_PAY
            )
            for (oemPayType in oemPayTypes) {
                when (oemPayType) {
                    OEMPayType.SAMSUNG_PAY -> {
                        oemConfig.serviceId = "SERVICEID"
                        oemConfig.context = applicationContext
                        oemConfig.visaClientAppId = "VisaClientAppID";
                    }
                    OEMPayType.HUAWEI_PAY -> {
                        val callbackUrl = "tpcsdk://com.thalesgroup.tpc.demo/tokenRequestorsPage"
                        oemConfig.callbackUrl = callbackUrl
                        oemConfig.activity = activity
                    }
                    OEMPayType.GOOGLE_PAY -> {
                        // Push Provisioning SDK V1.9.0 以降、Google Pay 用の Push Provisioning SDK 構成時に、Application は `Context` を `Activity` の代わりに設定できます
                        oemConfig.context = applicationContext
                    }
                }
                configSdk(oemPayType, oemConfig).collect{
                    println(it)
                }
            }
        }
    }

    private fun configSdkForScheme(configs: Config): Flow<TPCResult<Boolean>> = callbackFlow {
        // Push Provisioning SDK V2.0.0 以降、スキーム プッシュ プロビジョニングでは OEMPayType を設定しないでください
        val callBack = object : TPCSDKListener<Boolean?> {
            override fun onStart() {}

            override fun onSuccess(result: TPCResult<Boolean?>) {
                Log.d("CONFIG_SDK", "Scheme configuration successful...")
                channel.close()
            }

            override fun onError(exception: TPCSDKException) {
                Log.e("CONFIG_SDK", "Scheme configuration failed with error: " + exception.message)
                channel.close()
            }
        }
        TPCManager.getInstance().config(configs, callBack)
    }

    private fun configSdk(oemPayType: OEMPayType, configs: Config): Flow<TPCResult<Boolean>> =  callbackFlow {
        configs.oemPayType = oemPayType;
        val callBack = object : TPCSDKListener<Boolean?> {
            override fun onStart() {}
            override fun onSuccess(result: TPCResult<Boolean?>) {
                Log.d("CONFIG_SDK", "Configuration successful..." + oemPayType.oemType)
                channel.close()
            }

            override fun onError(exception: TPCSDKException) {
                Log.e("CONFIG_SDK", "Configuration setup failed with error: " + exception.message)
                channel.close()

            }
        }
        TPCManager.getInstance().config(configs, callBack)
        
    }
}
```

{% endtab %}
{% endtabs %}

#### Samsung Pay の設定 <a href="#samsung-pay-configurations" id="samsung-pay-configurations"></a>

Android R（target SDK 30）以降では、宣言する必要があります `<queries>` を Android マニフェスト ファイル内で。

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" 
  package="xxx.xxx.xxx.xxx">
  
  <application>
    <!-- Samsung Pay 用 -->
    <meta-data
      android:name="debug_mode"
      android:value="${DEBUG_MODE}" />
    <!-- Samsung Pay 用 -->
    <meta-data
      android:name="spay_sdk_api_level"
      android:value="${SPAY_API_LEVEL}" />
  </application>
  
  <queries>
    <package android:name="com.samsung.android.spay" />
    <package android:name="com.samsung.android.samsungpay.gear" />
  </queries>
```

### 難読化 <a href="#obfuscation" id="obfuscation"></a>

Samsung Pay で ProGuard の問題がある場合は、次のルールを使用してください。

<pre><code># Samsung Pay
-keep class com.samsung.android.sdk.** { *; }
<strong>-keep interface com.samsung.android.sdk.** { *; }
</strong></code></pre>

以下は Google 推奨の難読化ルールです。

{% code overflow="wrap" %}

```
# Google Pay
# TapAndPay SDK のクライアントクラスとインターフェースを保持します
-keep class com.google.android.gms.tapandpay.** { *; }

# SafeParcelable クラスとその CREATOR フィールドの除去や名前変更を防ぎます
-keep class * implements com.google.android.gms.common.internal.safeparcelable.SafeParcelable {
    public static final android.os.Parcelable$Creator *;
}

# 標準の Parcelable creator フィールドを保持します
-keepclassmembers class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator CREATOR;
}

```

{% endcode %}


---

# 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/classic-push-provisioning/ja/gaido/sdk-she-ding/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.
