# Integrate the SDK package for Android

> This topic covers how to easily integrate the Android SDK package with Maven and by manual integration.

This topic covers how to easily integrate the Android SDK package with Maven and by manual integration. Before beginning the integration, ensure that you have completed the following environment preparations:

-   Install the latest version of Android Studio.
-   Use target API level 19 or later.
-   Use Gradle 4.1 or later.
-   Configure a physical machine or emulator to run your application.

## Use Maven

Please follow the steps below to integrate the SDK package with Maven.

1.  Add the Maven repository:

Add the Maven repository to your root _build.gradle_ file using the code snippet below.

```groovy
allprojects {
    repositories {
        maven{
            credentials{
                username "antomsdk@aliyun.com"
                password "Admin1234"
            }
            url "https://globaltech.alipay.com/api/v1/file/repository/antom/"
        }
        // other repositories
        // -------
    }
}
```

2.  Add dependencies:

Add the dependencies in the _build.gradle_ file using the code snippet below.

```groovy
// 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](https://docs.antom.com/ac/sdks/sdk_release_note.md).

```groovy
ext {
    antom_version = 'ANTOM_VERSION'
}
```

3.  (Optional) Integrate the security 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.

> Note: If you are integrating the EasySafePay, please install this security package.

```groovy
dependencies {
    implementation "com.alipay.antom.sdk:securitysdk:1.1.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.

```groovy
android {
    useLibrary 'org.apache.http.legacy' // Support HttpClient
    ......
        }
```

-   Declare the usage of the _org.apache.http.legacy_ library in the _AndroidManifest.xml_ file.

```xml
<application>
  <uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
```

-   Integrate the [fastjson](https://github.com/alibaba/fastjson/wiki/Quick-Start-CN) parsing library

```groovy
dependencies {
    implementation 'com.alibaba:fastjson:1.1.70.android'
}
```

## Integrate manually

If you are not using Maven integration, you can follow the manual integration method provided by Antom.

1.  Download the latest SDK package in [Alipay Global Partner Developer Center](https://global.alipay.com/open/console/developer/app/list?_route=SG).

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.

2.  Place the unzipped _.aar_ file in the _libs_ folder of your project.
3.  Declare the reference of the _.aar_ file in the project's _build.gradle_ file.

```groovy
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')

    // Configure the AlipaySDK aar package.
    implementation(name: 'alipaysdk-android-15.8.35', ext: 'aar')
}
```