# Android > Getting started

Source: https://help-display-sdk.equativ.com/android/gettingstarted.html

This page explains how to install the **Equativ Display SDK** into an Android application. This is the first step to complete before delivering ads in your application.

---

## Prerequisites

There are some prerequisites prior to integrating the **Equativ Display SDK** in your application:
- **Android Studio**.
- **Android 6** _(API level 23)_ or higher.

## Google Advertising ID

The **Equativ Display SDK** uses the _Google Advertising ID_ of the device, which will be sent during ad calls. You should always comply with your local laws, check the [Privacy laws compliancy](https://help-display-sdk.equativ.com/privacy.html.md) page for more details.

The _Google Advertising ID_ might be unavailable on some devices, either because the user has opted-out in the device settings or because the device does not implement the _Google Play Services_.

## Installation

To import the **Equativ Display SDK** into your Android project, here are the steps to follow:

1. In the main `build.gradle` of your project, you must declare the repository where the **Equativ Display SDK** is hosted:

    ``` groovy
allprojects {
    repositories {
        google()

        // add the Equativ repository
        maven { url 'https://packagecloud.io/smartadserver/android/maven2' }

        // …
    }
}
```

    If you intend to support Huawei devices that do not feature Google services anymore (needed for Advertising Id retrieval), you also need to declare the Huawei support libraries repository:
    ``` groovy
        // Optional: Huawei services dependencies repository
        maven { url 'https://developer.huawei.com/repo/' }
    ```

    If you do not plan on supporting Huawei devices and their specific Advertising Id (counterpart of Google's Advertising Id), you can omit to declare the Huawei repository.
    Note that Advertising Id will be missing on Huawei devices, hence disabling all kinds of targeting options that require device identification.

2. In the `dependencies` section of your application module `build.gradle` file, declare the **Equativ Display SDK** artifact dependency:

    ``` groovy
dependencies {
    // Add Equativ Display SDK
    implementation 'com.equativ.android:equativ-display-sdk:8.6.1'

    // …
}
```

    All dependencies needed by the **Equativ Display SDK** will be automatically imported by Gradle.

    If you intend to support Huawei devices, you can also add the optional Huawei support library:
    ```groovy
    // Optional : add Smart support library for Huawei devices
    implementation 'com.smartadserver.android:smart-core-sdk-huawei-support:2.0.0'
    ```

    Reminder: If you do not plan on supporting Huawei devices and their specific Advertising Id (counterpart of Google's Advertising Id), you can omit to declare the Huawei dependency.
    Note that Advertising Id will be missing on Huawei devices, hence disabling all kinds of targeting options that require device identification.

1. In the `android` section of your application module `build.gradle` file, add the Java 8 compile options needed by some imported libraries:

   ```
android {
    // …

    compileOptions {
        targetCompatibility = JavaVersion.VERSION_1_8
        sourceCompatibility = JavaVersion.VERSION_1_8
    }
}
   ```

1. You can now proceed with the integration of your ads directly within your project's workspace.

   You can start by integrating a [banner ad](https://help-display-sdk.equativ.com/android/integration/banner.html.md) or an [interstitial](https://help-display-sdk.equativ.com/android/integration/interstitial.html.md).

## Location

For ad targeting purposes, the **Equativ Display SDK** can automatically send the latest known user location, _if already made available to the application_ (The **Equativ Display SDK** will never actively try to retrieve user location).

This automatic location retrieval is disabled by default, and you can enable as follows, provided that one of the location permissions is granted to the application, and that the User consent was properly collected for ad targeting purpose regarding his location.

```kotlin
SASConfiguration.automaticLocationDetectionAllowed = true
```

## Digital Service Act (DSA) integration

The __Digital Services Act (DSA)__ is a European Union regulation that entered into force on February 17th, 2024. It applies to any intermediary services and platforms offered to a European Economic Area (EEA) audience,
which means that companies established outside of the EEA may also be subject to this regulation.

For more information about the Digital Service Act, please check this [dedicated article · ](https://help.smartadserver.com/s/article/Digital-Services-Act-DSA).

You can set up your __DSA__ configuration by using the _SASConfiguration_ singleton, like in the example below:

``` kotlin
SASConfiguration.digitalServiceActConfig = SASDigitalServiceActConfig(
    SASDigitalServiceActConfigDSARequired.REQUIRED,
    SASDigitalServiceActConfigDataToPub.OPTIONAL_TO_SEND_TRANSPARENCY_DATA,
    listOf(SASDigitalServiceActConfigTransparency("https://domain.com", listOf(1, 2)))
)
```

For more information about the meaning of each parameters, please check the [official IAB specs · ](https://github.com/InteractiveAdvertisingBureau/openrtb/blob/main/extensions/community_extensions/dsa_transparency.md).

## Network Security Configuration

Since **Android 9 (API level 28)**, the default [network security configuration](https://developer.android.com/training/articles/security-config) is not as lenient as it was on previous versions: all network requests must use HTTPS protocol, basic HTTP requests will be blocked by default.

Even though the ad industry progresses towards full HTTPS support, it might happen that some medias are not hosted on secured servers.
To avoid your ads being blocked by the default network security configuration, you should create your own network security configuration XML file.

In your `res` folder, create the folder `xml` (if not created yet) then inside that folder create a file named `network_security_configuration.xml`.

Your file must be formatted like this (note: this was the default network security configuration for Android 6.0 (API level 23)):

```xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </base-config>
</network-security-config>
```

Once the file created, make sure to add `android:networkSecurityConfig="@xml/network_security_config"` in the `application` tag of your `AndroidManifest.xml` file. For instance:

```xml
<application
  android:name=".MyApplication"
  android:icon="@mipmap/ic_launcher"
  android:label="@string/app_name"
  android:networkSecurityConfig="@xml/network_security_config">
</application>
```
