Using the Android SDK {#concept_efq_v1c_fqb}
============================================

A mobile SDK is available for integrating payer authentication services into mobile applications running on the Android platform.

Updating the Gradle Build Properties {#reference_lrk_l5d_xpb}
=============================================================

In Android Studio, open the app directory (which can also be labeled Module: app) and open the *build.gradle* file. Edit the Gradle file located in the app directory. Add the contents shown in the example below to the Gradle file.

```
repositories {
   ...
   maven {
           url  "https://cardinalcommerceprod.jfrog.io/artifactory/android"
           credentials {
                   username Artifactory username
                   password Artifactory user API Key
            }
    }
}
dependencies {
    ...
    //Cardinal Mobile SDK
    implementation 2.5-1
}                
        
```

If your project uses Progurad, add the lines shown below to the *proguard-rules.pro* file.

```
-keep class com.cardinalcommerce.dependencies.internal.bouncycastle.**
-keep class com.cardinalcommerce.dependencies.internal.nimbusds.**
    
```

Configuring the Android SDK {#reference_hrm_syd_xpb}
====================================================

Get the instance of the Cardinal object by running the *Cardinal.getInstance()* process. Use the default configuration options. See the example below to understand how to run the *Cardinal.configure()* process.  
For more details on configuration, refer to the configuration options table after the example.

```
private Cardinal cardinal = Cardinal.getInstance();
@Override
protected void onCreate(Bundle savedInstanceState) {

CardinalConfigurationParameters cardinalConfigurationParameters = new CardinalConfigurationParameters();
        cardinalConfigurationParameters.setEnvironment(CardinalEnvironment.STAGING);
        cardinalConfigurationParameters.setTimeout(8000);
        JSONArray rType = new JSONArray();
        rType.put(CardinalRenderType.OTP);
        rType.put(CardinalRenderType.SINGLE_SELECT);
        rType.put(CardinalRenderType.MULTI_SELECT);
        rType.put(CardinalRenderType.OOB);
        rType.put(CardinalRenderType.HTML);
        cardinalConfigurationParameters.setRenderType(rType);

        cardinalConfigurationParameters.setUiType(CardinalUiType.BOTH);

        UiCustomization yourUICustomizationObject = new UiCustomization();
cardinalConfigurationParameters.setUICustomization(yourUICustomizationObject);

        cardinal.configure(this,cardinalConfigurationParameters);
}          
```

| Method                                                                                 | Description                                                                                                                          | Default Values                                                                                                                                                                                                                             |
|:---------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| setEnableDFSync (boolean enableDFSync)                                                 | On setting true, onSetupCompleted is called after the collected device data is sent to the server.                                   | False                                                                                                                                                                                                                                      |
| setEnableQuickAuth (boolean enableQuickAuth)                                           | Sets enable quick auth false.                                                                                                        | False                                                                                                                                                                                                                                      |
| setEnvironment(Setting up mobile SDK - Android- V 2.1#CardinalEnvironment environment) | Sets the environment to which the SDK must connect.                                                                                  | CardinalEnvironment. PRODUCTION                                                                                                                                                                                                            |
| setProxyAddress(java.lang. String proxyAddress)                                        | Sets the proxy to which the SDK must connect.                                                                                        | " "                                                                                                                                                                                                                                        |
| setRenderType(org.json. JSONArray renderType)                                          | Sets renderLists all user interface types that the device supports for displaying specific challenge user interfaces within the SDK. | JSONArray rType = new JSONArray(); rType.put(Cardinal RenderType.OTP); rType.put(Cardinal RenderType.SINGLE_SELECT); rType.put(Cardinal RenderType.MULTI_SELECT); rType.put(Cardinal RenderType.OOB); rType.put(Cardinal RenderType.HTML); |
| setTimeout(int timeout)                                                                | Sets the maximum amount of time (in milliseconds) for all exchanges.                                                                 | 8000                                                                                                                                                                                                                                       |
| setUICustomization (UiCustomization UI Customization)                                  | Sets UICustomization                                                                                                                 | Device Default Values                                                                                                                                                                                                                      |
| setUiType(CardinalUiType uiType)                                                       | Sets all user interface types that the device supports for displaying specific challenge user interfaces within the SDK.             | CardinalUiType.BOTH                                                                                                                                                                                                                        |
[Android Configuration Options]

Setting Up the Initial Request {#reference_usw_hb2_xpb}
=======================================================

Run the *Cardinal.init()* process to:

* Begin the communication process with Cardinal.
* Authenticate your credentials (server JWT).
* Complete the data collection process.

{#reference_usw_hb2_xpb_ul_zns_dwc_fwb}  
By the time the customer is ready to check out, all necessary preprocessing is complete.  
Each time a user begins a mobile transaction, Cardinal assigns a unique identifier to the consumer session called a consumerSessionId. This consumerSessionId ensures that Cardinal matches the correct device data collection results to a request. `Cybersource` calls this session identifier payerAuthEnrollService_referenceID. You must assign the value of the consumerSessionId field to the payerAuthEnrollService_referenceID field so that `Cybersource` can also track the calls for each user session.  
Study the code example shown below for completing the *cardinal.init()* process. Cardinal.init() (Android SDK)

```
cardinal = Cardinal.getInstance();
String serverJwt = "INSERT_YOUR_JWT_HERE";
cardinal.init(serverJwt ,
new CardinalInitService() {
    /**
    * You may have your Submit button disabled on page load. Once you are 
    * set up for CCA, you may then enable it. This will prevent users 
    * from submitting their order before CCA is ready.
    */
    @Override
    public void onSetupCompleted(String consumerSessionId) {
  
    }
    /**
    * If there was an error with set up, Cardinal will call this function
    * with validate response and empty serverJWT
    * @param validateResponse
    * @param serverJwt will be an empty
    */
    @Override
    public void onValidated(ValidateResponse validateResponse, String serverJwt) {
  
    }
});
```

See [Running Payer Authentication with SDK](/docs/cybs/en-us/payer-authentication/developer/all/rest/payer-auth/pa-sdk-intro/pa-sdk-implementing-sdk-pa.md "") for the next steps.
