すべてのプロダクト
Search
ドキュメントセンター

ID Verification:Android 統合

最終更新日:Oct 28, 2026

ID Verification Android SDK を統合して、eKYC リモート本人確認をアプリケーションに追加します。 サーバー側の Initialize API からトランザクション ID を取得し、それを SDK に渡して検証を開始します。

制限事項

Android 4.3 以降のスマートフォンおよびタブレットでサポートされています。

x86 デバイスはサポートされていません。

必要な権限

SDK は、ランタイムに次の権限を必要とします。

権限

必須

説明

android.permission.INTERNET

はい

ネットワークへのアクセスに必要です。

android.permission.ACCESS_NETWORK_STATE

いいえ (推奨)

android.permission.CAMERA

はい

顔スキャンに必要です。Android 6.0 以降では動的権限が必要です。

android.permission.WRITE_EXTERNAL_STORAGE

いいえ

com.aliyun.dpa:oss-android-sdk:$version コンポーネントは、この権限を自動的に宣言します。アプリケーションでこの権限が不要な場合は、remove タグを使用して AndroidManifest.xml から削除してください:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:remove="true" />

SDK のダウンロードと設定

  1. クライアント SDK リリースノートから AAR パッケージをダウンロードします。Android デモをダウンロードして、機能を試すこともできます。

  2. AAR ファイルをプロジェクトの libs ディレクトリに展開し、これらの依存関係を build.gradle に追加します。

    dependencies {
        // SDK モジュール
        implementation files('libs/idv-identityplatform-xxx.aar') 
        implementation files('libs/idv-identityface-xxx.aar') 
        implementation files('libs/idv-identitycrypto-xxx.aar') 
        implementation files('libs/idv-identityocr-xxx.aar') 
        implementation files('libs/Android-AliyunFaceGuard-xxx.aar')
        implementation files('libs/idv-identitybase-sdk-xxx.aar') 
        implementation files('libs/idv-identityservice-sdk-xxx.aar') 
        implementation files('libs/idv-identityquality-sdk-xxx.aar') 
        implementation files('libs/idv-identityblink-sdk-xxx.aar')
        implementation files('libs/idv-identitymouth-sdk-xxx.aar')
    
        implementation files('libs/idv-identitymnn-xxx.aar') 
        implementation files('libs/idv-identityocrservice-xxx.aar') 
        implementation files('libs/idv-identitynfc-xxx.aar') 
        implementation files('libs/IDOCR_PubSDK_Android-1.0.0.aar') 
    
        // または、fileTree を使用して ID Verification SDK の AAR ファイルのディレクトリを指定します。
        //implementation(fileTree(dir: "libs", includes: ["*.aar"]))
    
        implementation "androidx.appcompat:appcompat:1.5.0"
        implementation "androidx.activity:activity:1.7.0"
        implementation "androidx.recyclerview:recyclerview:1.0.0"
        implementation 'com.squareup.okhttp3:okhttp:4.9.3'
        implementation 'com.squareup.okio:okio:2.8.0'
        implementation 'com.aliyun.dpa:oss-android-sdk:2.9.21'
        implementation 'com.alibaba:fastjson:1.2.83_noneautotype'
    }
    説明
    • xxx は SDK のバージョン番号です。

    • すべてのサードパーティの依存関係を含めてください。そうしないと、SDK が正常に機能しない場合があります。

    • tygerservice-xxx.aar はバージョン 1.3.4 で削除されました。

    • idv-identitymouth-sdk-xxx.aar はバージョン 1.3.6 で追加されました。

API リファレンス

SDK は、install、getMetaInfo、verify の 3 つの API を提供します。それぞれについて以下で説明します。

SDK の初期化 (install)

  • 関数プロトタイプ

    public void install(Context context);
    public void install(Context context,Map<String, String> options);
  • パラメーター

    • context: アプリケーションコンテキスト。

    • options: データ収集のためのオプションパラメーター。デフォルトは null です。次のパラメーターを受け入れます:

      重要
      • ID Verification クライアントには、デバイスヘルパーセキュリティモジュールが組み込まれています。さまざまなリージョンでのデータ収集要件に準拠するため、クライアントは複数のデータレポートサイトをサポートしています。CustomUrl および CustomHost パラメーターを使用して、ユーザー属性に基づいてレポートサイトを指定できます。

      • アプリケーションセッションのライフサイクルごとに、データレポートリージョンは 1 つしか指定できません。このリージョンは、サーバー側のクエリで使用されるリージョンと一致する必要があります。サーバー側のリージョンサポートはプロダクトによって異なります。詳細については、「サポートされているリージョン」をご参照ください。

      • リージョン別の CustomUrl 値:

        • 中国 (香港): https://cloudauth-device.cn-hongkong.aliyuncs.com

        • シンガポール: https://cloudauth-device.ap-southeast-1.aliyuncs.com

        • インドネシア (ジャカルタ): https://cloudauth-device.ap-southeast-5.aliyuncs.com

        • 米国 (シリコンバレー): https://cloudauth-device.us-west-1.aliyuncs.com

        • ドイツ (フランクフルト): https://cloudauth-device.eu-central-1.aliyuncs.com

        • マレーシア (クアラルンプール): https://cloudauth-device.ap-southeast-3.aliyuncs.com

      パラメーター

      説明

      例

      IPv6

      デバイス情報をレポートするために IPv6 ドメイン名を使用するかどうかを指定します:

      • 0 (デフォルト): いいえ (IPv4 ドメイン名を使用)

      • 1: はい (IPv6 ドメイン名を使用)

      "1"

      DataSwitch

      デバイス情報をレポートするタイミングを指定します。

      • 0 (デフォルト): 初期化時

      • 1: トークン取得時

      説明

      デフォルト設定を使用することを推奨します。

      "1"

      CustomUrl

      データレポートサーバーのドメイン名。

      詳細については、「リージョン別の CustomUrl 値」をご参照ください。

      CustomHost

      データレポートサーバーのホスト。

      "cloudauth-device.ap-southeast-1.aliyuncs.com"

      説明

      この例はシンガポールリージョン用です。他のリージョンのホストは、「リージョン別の CustomUrl 値」に記載されている URL から派生させることができます。

  • 戻り値: なし。

MetaInfo の取得 (getMetaInfo)

  • 関数プロトタイプ

    public static String getMetaInfo(Context context);
  • パラメーター

    名前

    タイプ

    説明

    context

    Context

    アプリケーションコンテキスト。

  • 戻り値: デバイス環境情報を含む JSON 文字列:

    {
      "apdidToken": "",
      "appName": "com.aliyun.identity.platform",
      "appVersion": "1.0.1",
      "bioMetaInfo": "5.1.0:11501568,4",
      "deviceBrand": "xxx",
      "deviceManufacturer": "xxx",
      "deviceModel": "xxx",
      "deviceType": "android",
      "identityVer": "1.0.0",
      "osVersion": "10",
      "sdkVersion": "1.0.9"
    }

検証の開始 (verify)

重要
  • verify を呼び出す前に、MetaInfo をサーバーに渡し、Initialize API からトランザクション ID を取得してください。

  • 新しいバージョンでは protocol フィールドが返されます。これを extParams で渡してください。

  • 関数プロトタイプ

    public void verify(String transactionId, Map<String, String> extParams, IdentityCallback callback);
  • パラメーター

    名前

    タイプ

    説明

    transactionId

    String

    サーバー側の Initialize API から取得した transactionId。

    重要

    TransactionId は、1 回の認証フローに対する一意の認証情報です。呼び出しごとに新しい TransactionId を使用する必要があります。

    TransactionId は、認証フローが成功、失敗、またはキャンセルされたかどうかにかかわらず、1 回使用すると有効期限が切れます。有効期限切れの TransactionId を再利用して SDK を呼び出さないでください。新しい認証を開始するには、クライアントはサーバーから新しい TransactionId をリクエストする必要があります。

    同じ TransactionId を再利用して SDK を呼び出すと、次の問題が発生する可能性があります:

    • 異常な状態とクラッシュ: SDK は新しいフローと再開されたフローを区別できません。これにより、UI の不具合、プロセスのフリーズ、または SDK のクラッシュが発生する可能性があります。

    • リスクコントロールによるブロック: 基盤となるセキュリティポリシーが、再利用をリプレイ攻撃として検出する可能性があります。このアクションは認証をブロックし、エラーを返します。

    • トラブルシューティングの失敗: 同じ ID が、複数の切断された操作ログに関連付けられます。これにより、顧客が問題を報告した場合に根本原因を見つけることが不可能になります。

    extParams

    Map<String, String>

    拡張パラメーター。不要な場合は null を渡します。

    サポートされているフィールド: extParams の設定に関する説明。

    callback

    IdentityCallback

    この Webhook は認証結果を配信します。コールバックのリターンコードの詳細については、「ネイティブ SDK クライアントのリターンコードとサブコード」をご参照ください。

    コールバックの定義:

    public class IdentityResponse {
        // 「リターンコード」の説明をご参照ください。
        public int code;
    
        // リターンコードの説明。
        public String message;
    }
    
    public interface IdentityCallback {
        boolean response(IdentityResponse response);
    }
  • extParams の設定に関する説明

    キー

    説明

    例 (文字列型)

    IdentityParams.OcrResultButtonColor

    OCR 結果ページのボタンの色。

    #FF0000

    IdentityParams.RoundProgressColor

    顔スキャン中の円の色。

    #FF0000

    IdentityParams.ShowBlbumIcon

    OCR 中にアルバムアップロードのエントリを表示します:

    • 1 (デフォルト): 表示

    • 0: 非表示

    1

    IdentityParams.ShowOcrResult

    OCR 認識結果ページを表示します:

    • 1 (デフォルト): 表示

    • 0: 非表示

    1

    IdentityParams.EditOcrResult

    OCR 結果ページを編集可能にします:

    • 1 (デフォルト): 編集可能

    • 0: 編集不可

    1

    IdentityParams.MaxErrorTimes

    最大リトライ回数。

    範囲: 3~10。デフォルト: 10。

    10

    IdentityParams.CardOcrTimeOutPeriod

    OCR 認識タイムアウト。

    範囲: 20~60 秒。デフォルト: 20 秒。

    20

    IdentityParams.FaceVerifyTimeOutPeriod

    生体検知タイムアウト。

    範囲: 20~60 秒。デフォルト: 20 秒。

    20

    IdentityParams.OcrResultTimeOutPeriod

    OCR 結果ページの編集タイムアウト (秒単位)。

    デフォルト: 無制限。

    60

    IdentityParams.SdkLanguage

    SDK のカスタム表示言語を設定できます。デフォルトでは、モバイルデバイスのシステム言語が使用されます。

    説明

    サポートされている言語のリストについては、「Android および iOS SDK の言語カスタマイズ」をご参照ください。

    zh-Hans

    IdentityParams.CloseButtonLayout

    閉じるボタンのレイアウト:

    • left (デフォルト): 左側

    • right: 右側

    left

    IdentityParams.WaterMark

    OCR 成功後に表示されるウォーターマークテキスト。

    テスト用ウォーターマークテキスト

    IdentityParams.Protocol

    サーバー側の Initialize API 応答からのプロトコル文字列。

    説明

    サーバー側の Initialize API 応答から protocol 値を渡して、内部 API 呼び出しを減らし、パフォーマンスを向上させます。

    なし

リターンコード

詳細については、「ネイティブ SDK クライアントのリターンコードとサブコード」をご参照ください。

サンプルコード

public class MainActivity extends AppCompatActivity {
    private String transactionId = "";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        // SDK を初期化します
        IdentityPlatform.getInstance().install(MainActivity.this);
    
        // MetaInfo を取得します
        String metaInfo = IdentityPlatform.getMetaInfo(MainActivity.this);
    
        /**
         * MetaInfo をアプリケーションサーバーに送信します。クラウド側の Initialize API を呼び出して transactionId を取得します。
         * 新しいバージョンはプロトコルデータを返します。
         */
        // transactionId = getTransactionIdFromServer(metaInfo).transactionId;
        //protocol ==getTransactionIdFromServer(metaInfo).protocol;;
        
        Map<String, String> extParams = new HashMap();
        // プロトコルデータを設定します
        extParams.put(IdentityParams.PROTOCOL, protocol);
        // SDK の言語を設定します
        extParams.put(IdentityParams.SdkLanguage, "en");
        // 検証を開始します
        IdentityPlatform.getInstance().verify(transactionId, extParams,
                new IdentityCallback() {
                    @Override
                    public boolean response(final IdentityResponse response) {
                        if (IdentityResponseCode.IDENTITY_SUCCESS == response.code) {
                            Toast.makeText(MainActivity.this,
                                    "Verification passed", Toast.LENGTH_LONG).show();
                        } else {
                            Toast.makeText(MainActivity.this,
                                    "Verification failed([" + response.code + "]" +
                                            response.message + ")",
                                    Toast.LENGTH_LONG).show();
                        }
                        return true;
                    }
                });
    }
    
}

難読化ルール

-verbose
-keep class com.idv.identity.platform.api.** {*;}
-keep class com.idv.identity.platform.log.** {*;}
-keep class com.idv.identity.util.IdentityUtils {*;}
-keep class com.idv.identity.ocr.IdentityOcrApi {*;}
-keep class com.idv.identity.platform.model.** {*;}
-keep class com.idv.identity.platform.config.** {*;}
-keep class com.idv.identity.face.IdentityFaceApi {*;}


-keep class com.face.verify.intl.** {*;}
-keep class com.alibaba.fastjson.** {*;}
-keep class face.security.device.api.** {*;}
-keep class net.security.device.api.** {*;}
-keep class com.dtf.toyger.** { *; }
-dontwarn net.security.device.api.**
-dontwarn face.security.device.api.**


-keep class com.idv.identity.service.algorithm.** {*;}
-keep class com.idv.identity.base.algorithm.** {*;}
-keep class com.idv.identity.quality.QualityRouter {*;}
-keep class com.idv.identity.blink.BlinkRouter {*;}
-keep class com.idv.identity.service.IdentityFaceService {*;}
-keep class com.idv.identity.service.ocr.IdentityDocService {*;}
-keep class com.idv.identity.mouth.MouthRouter {*;}

-keep class com.alibaba.sdk.android.oss.** { *; }
-dontwarn okio.**
-dontwarn org.apache.commons.codec.binary.**



# NFC
-keep class com.idv.identity.nfc.IdentityNfcApi { *; }
-keep class org.jmrtd.** {*;}
-keep class net.sf.**{*;}
-keep class org.**{*;}
-keep class cn.**{*;}


# 警告を抑制するために、これらのルールを既存の keep ルールに追加してください。
# これは Android Gradle プラグインによって自動的に生成されます。
-dontwarn com.fasterxml.**
-dontwarn com.google.**
-dontwarn java.applet.Applet
-dontwarn java.awt.**
-dontwarn javax.**
-dontwarn org.**
-dontwarn retrofit2.**
-dontwarn springfox.documentation.spring.web.json.Json

# ログの難読化 (オプション)
-assumenosideeffects class android.util.Log {
    public static *** d(...);
}

# 1.3.2 より前のバージョンを使用している場合は、次の難読化ルールを追加します:
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.alibaba.fastjson.** { *; }
-keep class * extends com.alibaba.fastjson.TypeReference { *; }

コンポーネントのトリミング

SDK 統合フェーズ中に一部のコンポーネントをトリミングできます。SDK パッケージサイズを最小限に抑えるには、プロダクトで必要なコンポーネントのみを統合してください。これにより、完全な機能セットとセキュリティコンプライアンスが保証されます。詳細なトリミングルールについては、「SDK の軽量化手順」をご参照ください。