---
updatedAt: 2025-07-09T16:43:05.000Z
agentTools:
  projectIndex: https://docs.emergetools.com/llms.txt
---

# Setup SDK (Android)

Get started using Distribution for Android in under 10 minutes

[com.emergetools.distribution](https://github.com/EmergeTools/emerge-android/tree/main/distribution) is a Android library that simplifies the process of distributing new app versions and checking for updates. It provides an easy-to-use API to verify if a new version is available and handles the update process seamlessly, ensuring your team members are always on the latest release.

# Quick setup (\~10 minutes)

## Install the SDK

Latest versions:

* Distribution SDK [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.emergetools.distribution/distribution/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.emergetools.distribution/distribution)

```kotlin build.gradle.kts (app)
// app-module build.gradle.kts
dependencies {
  implementation("com.emergetools.distribution:distribution:<latest_version>")
}
```

## Configure the SDK

The SDK can be configured:

* Directly using `gradle`
* Manually in `AndroidManifest.xml`

The build distribution API key is included in prerelease versions of an app. It allows that app to determine if there are updates available and download those updates if so. The key can be found [here](https://www.emergetools.com/settings?tab=feature-configuration\&cards=distribution_enabled)

*via manifestPlaceholders*

```kotlin build.gradle.kts (app)
// app-module build.gradle.kts

android {
  // ...

  defaultConfig {
    // ...
    manifestPlaceholders["emerge.distribution.apiKey"] = ""
  }

  buildTypes {
    // ...
    staging {
      // ...
      manifestPlaceholders["emerge.distribution.apiKey"] = System.getenv("DISTRIBUTION_API_KEY")
    }
  }
}
```

## Checking for an update

In order to check for updates you call the `Distribution.checkForUpdate(context)` method. This is an async method which checks if an update is available. See also the [Distribution API](https://github.com/EmergeTools/emerge-android/blob/main/distribution/distribution/src/main/kotlin/com/emergetools/distribution/Distribution.kt).

### An explicit button

Here is an example of how `checkForUpdate` can be wired up to an explicit button.

<Image align="center" src="https://files.readme.io/cd399876d164cf073127bd8f123c8589f0a8c89d12c8878b83c84fc56a017acb-CleanShot_2024-12-12_at_17.40.23.mp4.gif" />

```kotlin
@Composable
fun MyCustomUpdaterButton() {
  val context = LocalContext.current
  Box {
    val scope = rememberCoroutineScope()
    var isLoading by remember { mutableStateOf(false) }
    var status by remember { mutableStateOf<UpdateStatus?>(null) }
    Button(onClick = {
      scope.launch {
        isLoading = true
        status = null
        status = Distribution.checkForUpdate(context)
        // If a new release is available download it:
        val myStatus = status
        if (myStatus is UpdateStatus.NewRelease) {
          Distribution.downloadUpdate(context, myStatus.info)
        }
        isLoading = false
      }
    }) {
      when (isLoading) {
        true -> Text(text = "Loading...")
        false -> when (status) {
          is UpdateStatus.UpToDate -> Text(text = "Up to date!")
          is UpdateStatus.Error -> Text(text = (status as UpdateStatus.Error).message)
          is UpdateStatus.NewRelease -> Text(text = "New release!")
          else -> Text(text = "Check for updates")
        }
      }
    }
  }
}
```

# SDK initialization

## Automatic initialization

Distribution relies on the [Androidx startup library](https://developer.android.com/topic/libraries/app-startup) to auto-initialize the Distribution SDK as part of your app's startup.

## Disable automatic initialization

To disable automatic initialization add the following snippet to your app's `AndroidManifest.xml`:

```xml AndroidManifest.xml
<provider
  android:name="androidx.startup.InitializationProvider"
  android:authorities="${applicationId}.androidx-startup"
  android:exported="false"
  tools:node="merge">
  <meta-data android:name="com.emergetools.distribution.DistributionInitializer"
    tools:node="remove" />
</provider>
```

You may need to add a direct dependency on the`androidx.startup:startup-runtime` library if the app does not already have such a dependency.

```kotlin build.gradle.kts (app)
// app-module build.gradle.kts
dependencies {
  implementation("androidx.startup:startup-runtime:<latest_version>")
}
```

Follow the [Manual initialization](#manual-initialization) steps below to ensure that Distribution is initialized.

## Manual initialization

To manually initialize Distribution call `Distribution.init(context)`. For example:

```kotlin MyApp.kt
import com.emergetools.distribution.Distribution

class MyApp : Application() {
  override fun onCreate() {
    Distribution.init(this)
  }
}
```
```java MyApp.java
import com.emergetools.reaper.Reaper;

public class MyApp extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    Reaper.init(this);
  }
}
```

A common case when manual initialization is required is when `androidx.startup.InitializationProvider` has been [globally disabled](https://developer.android.com/develop/background-work/background-tasks/persistent/configuration/custom-configuration?_gl=1*zaner1*_up*MQ..*_ga*Mzg1MDcwNDgwLjE3MjA3MDc2MDI.*_ga_6HH9YJMN9M*MTcyMDcwNzYwMi4xLjAuMTcyMDcwNzYwMi4wLjAuMA..#remove-default)  by the following snippet being included in the `AndroidManifest.xml`:

```xml AndroidManifest.xml
<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    tools:node="remove">
  <meta-data
        android:name="androidx.work.WorkManagerInitializer"
        android:value="androidx.startup"
        tools:node="remove" />
</provider>
```

# Examples

* [Minimized example](https://github.com/EmergeTools/emerge-android/tree/main/distribution/sample/app)
* [Hackernews example app](https://github.com/EmergeTools/hackernews/blob/b52c577cd951d5f15256c91d3bff7e05fe96e293/android/app/src/main/java/com/emergetools/hackernews/features/settings/SettingsScreen.kt#L192)