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

# Android

> OTA SDK for Kotlin and Java Android apps

<Card title="phrase/phrase-android" icon="github" horizontal href="https://github.com/phrase/phrase-android" />

<Card title="phrase/android-sdk-example" icon="github" horizontal href="https://github.com/phrase/android-sdk-example" />

The Phrase Android SDK fetches OTA translation releases at runtime and caches them on-device. If the OTA service is unreachable, the SDK falls back to the last cached translations or to the strings bundled in your app binary.

For more information on requirements and supported platforms, see the repository [README](https://github.com/phrase/phrase-android).

## Installation

Add the Phrase Maven repository to your root `build.gradle`, then add the SDK dependency:

```gradle theme={null}
// root build.gradle
allprojects {
    repositories {
        maven { url "https://maven.download.phrase.com" }
    }
}

// app/build.gradle
dependencies {
    // With Jetpack Compose support
    implementation "com.phrase.android:ota-sdk-compose:<version number>"

    // Without Compose (views only)
    // implementation "com.phrase.android:ota-sdk:<version number>"
}
```

## Setup

Initialize in your `Application` class and trigger the initial fetch. Both values are available in the Phrase Strings dashboard after creating a distribution, or via the [Distributions API](/en/api/strings/introduction):

```kotlin theme={null}
class MainApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Phrase.setup(this, "YOUR_DISTRIBUTION_ID", "YOUR_ENVIRONMENT_SECRET")
        Phrase.updateTranslations()
    }
}
```

To react to the result:

```kotlin theme={null}
Phrase.updateTranslations(object : TranslationsSyncCallback {
    override fun onSuccess(translationsChanged: Boolean) { }
    override fun onFailure() { }
})
```

## Using translations

**Jetpack Compose:**

```kotlin theme={null}
Text(phraseString(R.string.your_key))
```

**Android Views — base activity pattern:**

```kotlin theme={null}
open class BaseActivity : AppCompatActivity() {
    override fun getDelegate() = Phrase.getDelegate(this, wrapContext = false)
}
```

Layouts can then reference `@string/your_key` as normal; the SDK intercepts the resource lookup.

**Programmatic access:**

```kotlin theme={null}
textView.setText(context.getPhraseString(R.string.your_key))
```

## Configuration options

```kotlin theme={null}
Phrase.setTimeout(20_000)              // Network timeout in ms (default: 10,000)
Phrase.setDatacenter(Datacenter.US)    // Use the US data center (default: EU)
Phrase.setAppVersion("2.1.0")          // Override detected app version for release targeting
```

`setAppVersion` is useful if your `versionName` does not follow `<major>.<minor>.<patch>` format, which is required for [semantic version targeting](/en/ota/introduction#releases).
