A small native Android application written in Kotlin, showing how to use the published Messagevisor Java SDK.
The application downloads a production Messagevisor datafile, creates an SDK instance with the ICU module, and renders plain and formatted translations.
Learn more at messagevisor.com.
Install Android Studio with Android SDK 36 and JDK 17.
The project uses the Kotlin support built into Android Gradle Plugin 9, so it does not require the older Kotlin Android Gradle plugin.
Messagevisor Java is published through GitHub Packages. Add your GitHub username and a personal access token with the read:packages scope to ~/.gradle/gradle.properties:
gpr.user=YOUR_GITHUB_USERNAME
gpr.key=YOUR_GITHUB_TOKENKeep these credentials outside the repository. For GitHub Actions, grant the example repository read access to the Messagevisor Java packages.
- Open the repository in Android Studio.
- Allow Gradle to sync and resolve Messagevisor Java 0.2.0.
- Select an Android emulator or connected device.
- Run the
appconfiguration.
The application fetches this production datafile:
https://messagevisor-example-cloudflare-pages.pages.dev/production/messagevisor-mobile-en-US.json
The important SDK usage is in MainActivity.kt:
val m = Messagevisor.create(
MessagevisorOptions.builder()
.datafile(datafileJson)
.timeZone("America/New_York")
.addModule(IcuModule.create())
.build(),
)
val signIn = m.translate("auth.signin")
val contact = m.translate(
"nav.contact",
mapOf("closingTime" to closingTime),
)Run unit tests, Android lint, and a debug build with:
make buildLearn more in the Messagevisor Java SDK documentation.