Android

Requirement

Environment

ItemDescription
Supported System VersionsAndroid 5.0 and above
Supported Architecturesarmeabi-v7a, arm64-v8a, x86, x86_64

Integration steps

Installation

Add Warehouse

Add the Maven repository configuration to the build.gradle file in the project root directory.

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

If your Gradle version is 7 or higher, please add the following configuration to your project's settings.gradle file.

repositories {
    ...
    mavenCentral()
}

Add Dependencies

In the build.gradle file of the application's main module, declare the SDK package dependencies.

dependencies {
    implementation 'com.trustdecision.android:mobrisk:5.1.3'
    implementation 'com.trustdecision.android:apisign:1.1.3'
 }

ABI Configuration

The SDK currently supports multiple ABI types. It is recommended that the user add the abiFilters configuration to the build.gradle file of the main module to select the required architecture type. For specific architectures, please refer to the architectures you need to support!

defaultConfig {
    ...
    ndk {
       abiFilters 'armeabi-v7a', 'arm64-v8a'
    }
}

Interface Signature

Definition

public static TDAPISignResult sign(Context context, String path);

结构体定义

public class TDAPISignResult {
  // Signature result
  private String sign;
  // Signature status code
  private int code;
  // Abnormal information
  private String msg;
}

Best Practices

The API to be protected is in the form of: https://sg.apitd.net/de/v1?name=jacky&age=12

TDAPISignResult signResult = TDRisk.sign(context, "de/v1");
if(signResult.code() == 0) {
  // Get signature
  String signature = signResult.signature();  
} else {
  // Get error messages and status codes
  String message = signResult.message();
  int code = signResult.code();
  // Continuing with the business logic, the signature here can be replaced with an empty character.
}

Status Check

If the status code obtained from the structure returned by the signature is 0, then the signature was successful.

TDAPISignResult.code == 0

Keep Configuration

If developers need to use proguard for obfuscation packaging, please add the following code to the proguard configuration file:

-keep class com.trustdecision.**{*;}

Status Code

CodeMessageRemarks
0/
2000path is emptyPlease set the path parameter.
22xxInternal errorPlease contact TD technical support.
4001The failure to call the .so file may be due to a missing .so file that the SDK depends onPlease check if the architecture used by the current device is configured in the project.
4002SDK call failedPlease check if the apisign module has been imported into your project.