|
| 1 | +--- |
| 2 | +id: installation |
| 3 | +title: Installation |
| 4 | +description: How to install Tolgee Android SDK in your Android project |
| 5 | +--- |
| 6 | + |
| 7 | +> **NOTE:** |
| 8 | +> For managing static translations, we recommend using [Tolgee CLI](https://github.com/tolgee/tolgee-cli). |
| 9 | +
|
| 10 | +## Requirements |
| 11 | + |
| 12 | +- **Android API Level**: 21+ (Android 5.0+) |
| 13 | + |
| 14 | +## Quickstart (Views) |
| 15 | + |
| 16 | +1. Add dependency (Core): |
| 17 | + |
| 18 | + Using Version Catalog is recommended to keep your versions aligned. |
| 19 | + |
| 20 | + ```toml |
| 21 | + # gradle/libs.versions.toml |
| 22 | + [libraries] |
| 23 | + tolgee = { group = "io.tolgee.mobile-kotlin-sdk", name = "core", version.ref = "tolgee" } |
| 24 | + ``` |
| 25 | + |
| 26 | + ```kotlin |
| 27 | + // build.gradle.kts (module) |
| 28 | + dependencies { |
| 29 | + implementation(libs.tolgee) |
| 30 | + } |
| 31 | + ``` |
| 32 | + |
| 33 | + If you use Jetpack Compose, see the Compose variant: [Jetpack Installation](/android-sdk/jetpack/installation) |
| 34 | + |
| 35 | +2. (If needed) Ensure repositories include Maven Central: |
| 36 | + |
| 37 | + ```kotlin |
| 38 | + // settings.gradle.kts or build.gradle.kts |
| 39 | + pluginManagement { repositories { gradlePluginPortal(); google(); mavenCentral() } } |
| 40 | + dependencyResolutionManagement { repositories { google(); mavenCentral() } } |
| 41 | + ``` |
| 42 | + |
| 43 | +3. Allow CDN networking (required when using Tolgee Cloud CDN): |
| 44 | + |
| 45 | + Create a network security config file `network_security.xml` in your `res/xml` folder: |
| 46 | + |
| 47 | +```xml |
| 48 | +<?xml version="1.0" encoding="utf-8"?> |
| 49 | +<network-security-config xmlns:android="http://schemas.android.com/apk/res/android"> |
| 50 | + <domain-config> |
| 51 | + <domain includeSubdomains="true">tolgee.io</domain> |
| 52 | + <domain includeSubdomains="true">tolg.ee</domain> |
| 53 | + </domain-config> |
| 54 | +</network-security-config> |
| 55 | +``` |
| 56 | + |
| 57 | +Add network security config to your `AndroidManifest.xml`: |
| 58 | + |
| 59 | +```xml |
| 60 | +<application |
| 61 | + android:networkSecurityConfig="@xml/network_security"> <!-- Add this line to your existing application tag --> |
| 62 | +</application> |
| 63 | +``` |
| 64 | + |
| 65 | +> NOTE: |
| 66 | +> Allowing `tolgee.io` and `tolg.ee` domains is required when using Tolgee Cloud CDN. If you only access your own self-hosted CDN, include your domain(s) accordingly. |
| 67 | +
|
| 68 | +## Initialization and configuration |
| 69 | + |
| 70 | +Initialize Tolgee in your `Application` class. |
| 71 | + |
| 72 | +```kotlin |
| 73 | +class MyApplication : Application() { |
| 74 | + override fun onCreate() { |
| 75 | + super.onCreate() |
| 76 | + Tolgee.init { |
| 77 | + contentDelivery { |
| 78 | + url = "https://cdn.tolg.ee/your-cdn-url-prefix" // from Tolgee Platform → Content Delivery |
| 79 | + storage = TolgeeStorageProviderAndroid(this@MyApplication, BuildConfig.VERSION_CODE) // cache invalidates on app update |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +How to get your CDN URL prefix (Content Delivery): |
| 87 | +- Open Tolgee Platform → your Project → Developer settings → Content Delivery. |
| 88 | +- Copy the full CDN URL prefix. You can use different prefixes per environment (dev/staging/prod). |
| 89 | +- Optional: Verify connectivity locally: |
| 90 | + |
| 91 | +```bash |
| 92 | +curl -I "https://cdn.tolg.ee/your-cdn-url-prefix/en.json" |
| 93 | +``` |
| 94 | + |
| 95 | +You should receive a 200 response. If you get 403/404, double‑check the prefix. |
| 96 | + |
| 97 | +> TIP: |
| 98 | +> For Activities, wrap the base context so `getString` and similar APIs use Tolgee. See step-by-step in [Usage](./usage.mdx). |
| 99 | +
|
| 100 | +## Next steps |
| 101 | + |
| 102 | +- Not sure which artifact to use? See [`Modules overview`](./modules.mdx) |
| 103 | +- Learn how to fetch and render translations in Views: [`Usage`](./usage.mdx) |
| 104 | +- Using Compose? Start here: [`Jetpack Installation`](./jetpack/installation.mdx) |
| 105 | +- Having issues? Check [`Troubleshooting`](./troubleshooting.mdx) |
| 106 | + |
0 commit comments