> ## Documentation Index
> Fetch the complete documentation index at: https://docs.suprsend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Android Integration

> This document will cover integration steps for Android side of your Flutter application.

## Installation

<Steps>
  <Step title="Open your Flutter project’s pubspec.yaml file">
    Add following line of code inside dependencies in pubspec.yaml file

    <CodeGroup>
      ```yaml pubsec.yaml theme={"system"}
      dependencies:
        flutter:
        	sdk: flutter
        suprsend_flutter_sdk: "^2.4.0"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run flutter pub get in the terminal">
    <CodeGroup>
      ```shell shell theme={"system"}
      flutter pub get
      ```
    </CodeGroup>

    <Warning>
      **Troubleshooting notes:**

      In case you face compilation errors or warnings, please perform the following troubleshooting steps:

      * Ensure mavenCentral is present under repositories in project's build.gradle

      * Perform gradle sync
    </Warning>
  </Step>
</Steps>

## Initialization

<Steps>
  <Step title="Initialize Suprsend Flutter SDK">
    To integrate SuprSend in your Android app, you will need to initialize the suprsend flutter SDK in your MainApplication class.

    <Note>
      **Note**: **SSApi.init** should only be called in Application class, not inside Activity class(**MainActivity.kt**). If your project does not have an Application class, create it manually and register it in the AndroidManifest.
    </Note>

    Example: If you create a new Application class named [MainApplication.kt](https://github.com/suprsend/suprsend-flutter-sdk/blob/main/example/android/app/src/main/kotlin/com/suprsend/suprsend_flutter_sdk_example/SuprsendFlutterPluginTestApplication.kt) in your source package, go to your AndroidManifest file and enter the path of the class in the tag like this:

    <CodeGroup>
      ```xml AndroidManifest.xml theme={"system"}
      <application
         ...
         android:name=".MainApplication"
         ...
         >
      ```
    </CodeGroup>

    <CodeGroup>
      ```kotlin MainApplication.kt theme={"system"}
      package <your-package-name>

      import android.app.Application
      import app.suprsend.SSApi; // import sdk

      class MainApplication : Application(){

        override fun onCreate() {

         SSApi.init(this, WORKSPACE KEY, WORKSPACE SECRET) // Important! without this, SDK will not work
         SSApi.initXiaomi(this, xiaomi_app_id, xiaomi_api_key) // Optional. Add this if you want to support Xiaomi notifications framework

         super.onCreate()
        }
      }
      ```
    </CodeGroup>

    Replace **`WORKSPACE KEY`** and **`WORKSPACE SECRET`** with values linked to your account. You'll find it on SuprSend dashboard (Developers -> API Keys) page.&#x20;
  </Step>

  <Step title="Import SuprSend SDK in your client side code">
    Import suprsend SDK in your dart file. Go back to the flutter folder and follow below steps:

    <CodeGroup>
      ```javascript Main.dart theme={"system"}
      import 'package:suprsend_flutter_sdk/suprsend.dart';
      ```
    </CodeGroup>
  </Step>
</Steps>

## Logging

By default the logs of SuprSend SDK are disabled. We recommend you to enable the SDK logs by setting its value to VERBOSE. You can enable the logs just in debug mode while in development by below condition.

<CodeGroup>
  ```javascript Dart theme={"system"}
  suprsend.setLogLevel(level);

  suprsend.setLogLevel(LogLevels.VERBOSE);
  suprsend.setLogLevel(LogLevels.DEBUG);
  suprsend.setLogLevel(LogLevels.INFO);
  suprsend.setLogLevel(LogLevels.ERROR);
  suprsend.setLogLevel(LogLevels.OFF);

  ```
</CodeGroup>

***
