> For the complete documentation index, see [llms.txt](https://doc.appflow.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.appflow.ai/docs/sdk-set-up-instructions/android-sdk.md).

# Android SDK

Instructions to set up Appflow\.ai SDK for your Android app

***

{% hint style="danger" %} <mark style="color:red;">**Warning!**</mark>

Please note! We will be not able to receive and show your data without this step!
{% endhint %}

To connect your Android app to Appflow\.ai console you need to follow 3 steps during onboarding or using Settings=>Applications=>New Application

<figure><img src="https://1902080327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTUSTYqtR8RNNkx3qqWf9%2Fuploads%2FqXtCLzRi0YCx2VRZgDrr%2Fimage.png?alt=media&amp;token=81fe8e36-c873-431d-8d29-03843d919963" alt=""><figcaption></figcaption></figure>

1. First step is to download app token. Download and put it into the assets folder.
2. Second step is Install SDK. Install via Gradle

a. If your project doesn't have dependencyResolutionManagement in your settings.gradle, add the following to your top-level build.gradle at the end of repositories：

```kotlin
/** top-level build.gradle */
allprojects {
    repositories {
        ...
        maven { url 'https://maven.appflow.ai/repository/sdk' }
    }
}
```

Otherwise add the following to your settings.gradle in repositories of dependencyResolutionManagement section：

```kotlin
/** settings.gradle */
dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven { url 'https://maven.appflow.ai/repository/sdk' }
    }
}
```

b. add the dependency to your module-level build.gradle at the end of dependencies

```kotlin
/** module-level build.gradle */
dependencies {
    ...
    implementation 'com.imp:appflow:1.1.0'
}
```

3\. The step 3 is the most important - Initialize SDK

Add configuration file

Download the appflow-app-token.json file in the dash.appflow\.ai and add the file to the app\src\main\assets folder of the project&#x20;

Initialize&#x20;

Add the following to your Application class

```kotlin
override fun onCreate() {
    super.onCreate()
    Appflow.init(this)
}
```

If you want to know if the SDK is initialized, you can do the following

```kotlin
override fun onCreate() {
    super.onCreate()
    Appflow.init(this, AppflowConfig.Builder().build()) {
			//AppflowSDK initialization finished，do something
    }
}
```

Set user id (optional)

You can set the user id in the following way

```kotlin
override fun onCreate() {
    super.onCreate()
    Appflow.init(this, AppflowConfig.Builder().setAppUserID("your_user_id").build())
}
```

Enable SDK log (optional)&#x20;

You can enable SDK log output before initializing the SDK&#x20;

```kotlin
override fun onCreate() {
    super.onCreate()
    Appflow.setLogEnable(true)
    Appflow.init(this)
}
```

{% hint style="info" %}
Please, also follow the next step - adding keys for the RTDN access
{% endhint %}

{% hint style="danger" %} <mark style="color:red;">**Can't find topic name?**</mark>

Make sure you switched on [Google Pub/Sub](https://console.cloud.google.com/flows/enableapi?apiid=pubsub) for your project

* Find the Settings tab on your project.
* Click on "Stores"
* Then click "Connect to Google" in Google Developer Notification settings.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.appflow.ai/docs/sdk-set-up-instructions/android-sdk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
