Integrate the SDK Package for Android
This topic covers how to easily integrate the Android SDK package with Maven and by manual operation.
Integrate the SDK Package with Maven
Please follow the steps below to integrate the SDK package with Maven.
- Add the Maven repository:
Add the Maven repository to your root build.gradle file using the code snippet below.
allprojects {
repositories {
maven{
credentials{
username "antomsdk@aliyun.com"
password "Admin1234"
}
url "https://globaltech.alipay.com/api/v1/file/repository/antom/"
}
// other repositories
// -------
}
}
- Add dependencies:
Add the dependencies in the build.gradle file using the code snippet below.
// in app build.gradle
// if there are some conflicts with existing sdk, please exclude them
dependencies {
implementation "com.alipay.antom.sdk:payment-component:${antom_version}"
}
Externalize the dependency version in the build.gradle file to easily manage upgrades with the "Externalize dependency version" code snippet. Replace the value of ANTOM_VERSION
with the latest version 1.24.0.
ext {
antom_version = 'ANTOM_VERSION'
}
- (Optional) Integrate the security extension package:
Antom offers the SDK security extension package for a secure payment process. To integrate the security package, add the Maven dependencies in the build.gradle file with the code snippet below.
dependencies {
implementation "com.alipay.antom.sdk:securitysdk:1.0.0"
}
After integrating the security extension package, take note of the following:
- Use Apache HttpClient
- Declare the usage of the org.apache.http.legacy library in your project's root build.gradle file.
android {
useLibrary 'org.apache.http.legacy' // Support HttpClient
......
}
- Declare the usage of the org.apache.http.legacy library in the AndroidManifest.xml file.
<application>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
- Integrate the fastjson parsing library
dependencies {
implementation 'com.alibaba:fastjson:1.1.70.android'
}
Integrate the SDK Package manually
If you are not using Maven integration, you can follow the manual integration method provided by Antom.
- Download the latest SDK package in Alipay Global Partner Developer Center.
Go to Resources > Download Detail > Android, select the corresponding product package, and click on View the download address of this package to download. Accept the download agreement for the first download.
- Place the unzipped .aar file in the libs folder of your project.
- Declare the reference of the .aar file in the project's build.gradle file.
dependencies {
// Configure the SDK .aar package. Make sure to replace "xxxxx" with the actual version number of the downloaded package.
implementation(name: 'ams-component-sdk-release-xxxxx', ext: 'aar')