Skip to documentation
DocumentationSDKs and frameworks

Android

Set up the ReRune Android SDK with native Android resources in Compose or Views, including explicit refresh when published text changes.

Documented SDK 1.8.0

Requirements: Android API 21+, Kotlin or Java

Package referenceExplore Android localization
On this page

Choose Compose or Views

Gradle Kotlin DSL · choose the UI module

dependencies {
  // Compose
  implementation("io.rerune:rerune-android-compose:1.8.0")
  // Views
  implementation("io.rerune:rerune-android-views:1.8.0")
}

Choose the Compose or Views dependency for your app module and enable Maven Central. Keep your strings.xml and plural resources. You no longer need a packaging rule for license files. ReRune no longer includes OkHttp: if your app used OkHttp only because ReRune brought it in, add it to your own dependencies. The public example apps use the same 1.8.0 release.

Before you upgrade

Android SDK 1.8.0 and iOS SDK 1.7.0 still skip a whole language update when one published translation uses a placeholder your app does not provide, expects a different type of value, or has a placeholder that is not declared on its key. Users keep the last version that worked. With checkOnStart on, the default, both also check for updates whenever the app returns to the foreground. Android: after the upgrade each language downloads once more, a saved variant falls back to the setup variant, and remembered rejected versions are forgotten. reRuneObserveRevision now refreshes texts in place and keeps remembered state, and getString with format arguments that do not fit your own text throws, as Android does. iOS: 1.7.0 adds, removes, and changes no public API, so upgrading from 1.6.1 needs no source change. A persisted reRuneSetVariant or reRuneResetVariant call that is still running when a later reRuneSetup reads the saved selection no longer saves, so call reRuneSetVariant again after the new setup when the choice should still apply. When you upgrade from 1.5.x, keys your app ships only in its development language are also checked, so a language that 1.5.0 applied can be rejected. A remote value with arguments for a key your app does not ship is used only when the lookup passes a matching default value, and SwiftUI Text("key") shows ReRune values.

Connect the Android application

  1. Initialize ReRune.setup in the Application with the project read-only OTA Publish ID.
  2. Wrap the activity base context with newBase.reRune() so native resource lookup can resolve delivered strings.
  3. For Views, install ReRuneViews in the Application and rebind existing widget text when strings update. XML layouts are localized in activities with a layout inflater factory, such as every AppCompatActivity. Styled app strings keep their own text in getText and XML; OTA text replaces them through getString.
  4. For Compose, wrap the whole content of each setContent in reRuneObserveRevision. It refreshes ReRune texts in place, so remembered state, scroll positions, and text fields stay.

The runnable examples show the complete Application and Activity wiring. Compose uses reRuneObserveRevision; Views uses reRuneOnStringsUpdated with a lifecycle scope. Copy the setup for your SDK version together with its imports and lifecycle handling.

The fragments below belong in your existing Application and Activity. Register the Application class in AndroidManifest.xml. For Views, install the integration in Application.onCreate and add the update listener after view binding is initialized. Replace binding.title and R.string.title with your actual view and resource. SDK imports use rerune.ReRune and rerune.reRune; UI hooks are in rerune.compose and rerune.views.

Kotlin · Application.onCreate, after super.onCreate()

ReRune.setup(
  app = this,
  otaPublishId = "<READ_ONLY_OTA_PUBLISH_ID>",
)

Kotlin · Activity base context

override fun attachBaseContext(newBase: Context) {
  super.attachBaseContext(newBase.reRune())
}

Kotlin · inside a Compose screen

reRuneObserveRevision {
  Text(text = stringResource(R.string.title))
}

Kotlin · Application.onCreate, Views only

ReRuneViews.install(this)

Kotlin · Activity.onCreate, after initializing view binding

binding.title.text = getString(R.string.title)
reRuneOnStringsUpdated(lifecycleScope) {
  binding.title.text = getString(R.string.title)
}

Native resources and runtime languages

Continue using native resource identifiers in application code. Keep bundled resources for offline fallback and ensure quantity arguments match your plural resources. Rebind or recompose existing UI after an update; fetching data alone does not rewrite text already assigned to a widget. In Compose, a text read outside composition and kept, for example in a ViewModel or in a remember block without keys, is not refreshed; key that remember with ReRune.revisionFlow. The ReRuneUnkeyedRememberText lint check flags such code. After a switch to a language that is not loaded yet, the app shows its own text until ReRune loads it, then ReRune.revisionFlow increments.

Dashboard-managed languages can appear after a successful fetch. Use runtime locale availability for an in-app picker. On Android 14 and newer, the SDK can also update the system per-app language list through LocaleConfig. New resource IDs, application code, and store metadata still require their normal release or store update.

Verify delivery on a device

  1. Start with local resources and confirm the app renders without a network connection.
  2. Publish a changed value for an existing key and use the correct project OTA ID.
  3. Trigger an update check and confirm both newly created and already visible UI display the expected text.
  4. Restart offline after a successful fetch to check cache restoration.