@@ -10,9 +10,16 @@ Install the Kotlin SDK
10
10
:depth: 2
11
11
:class: singlecol
12
12
13
+ .. meta::
14
+ :description: Learn how to install the Atlas Device SDK for Kotlin in your Android and Kotlin Multiplatform (KMP) projects.
15
+ :keywords: code example
13
16
14
- The Kotlin SDK supports two platforms, each with its own installation
15
- method:
17
+ .. facet::
18
+ :name: genre
19
+ :values: tutorial
20
+
21
+ The Atlas Device SDK for Kotlin supports the following platforms. Each has its own installation
22
+ method and requirements:
16
23
17
24
- :ref:`Android <kotlin-install-android>`
18
25
- :ref:`Kotlin Multiplatform (KMP) <kotlin-install-kotlin-multiplatform>`
@@ -28,19 +35,21 @@ meets the following prerequisites:
28
35
- Kotlin Plugin for Android Studio, version 1.6.10 or higher.
29
36
- An Android Virtual Device (AVD) using a supported CPU architecture.
30
37
38
+ For a list of supported target environments, refer to the :ref:`kotlin-supported-environments` section on this page.
39
+
31
40
Additionally, Kotlin Multiplatform (KMP) for mobile projects require the following:
32
41
33
42
- `Kotlin Multiplatform Mobile (KMM) Plugin
34
43
<https://kotlinlang.org/docs/mobile/kmm-plugin-releases.html#release-details>`__
35
44
for Android Studio, version 0.3.1 or higher.
36
- - A Kotlin Multiplatform (KMP) App created using the "Kotlin Multiplatform App"
37
- template in Android Studio. Follow the instructions in the
38
- `Kotlin Multiplatform documentation
45
+ - A Kotlin Multiplatform (KMP) App created using the "Kotlin Multiplatform App"
46
+ template in Android Studio. Follow the instructions in the
47
+ `Kotlin Multiplatform documentation
39
48
<https://kotlinlang.org/docs/mobile/create-first-app.html>`__.
40
49
41
50
For more details on setting up your KMP environment, refer to the `official Kotlin
42
- Kotlin Multiplatform for mobile documentation
43
- <https://kotlinlang.org/docs/multiplatform-mobile-setup.html>`__. To verify your
51
+ Kotlin Multiplatform for mobile
52
+ <https://kotlinlang.org/docs/multiplatform-mobile-setup.html>`__ documentation . To verify your
44
53
environment setup, follow Kotlin's `guide to checking your
45
54
environment
46
55
<https://kotlinlang.org/docs/multiplatform-mobile-setup.html#check-your-environment>`__.
@@ -50,8 +59,8 @@ environment
50
59
The Kotlin Multiplatform (KMP) ecosystem frequently changes. If you experience
51
60
any issues installing the SDK, check your Kotlin Plugin version, since
52
61
outdated plugins can lead to difficult to debug errors. To see which
53
- versions of the Kotlin Plugin are compatible with the SDK, see the
54
- `realm-kotlin changelog <https://github.com/realm/realm-kotlin/blob/master/CHANGELOG.md>`__.
62
+ versions of the Kotlin Plugin are compatible with the SDK, refer to the
63
+ `SDK changelog <https://github.com/realm/realm-kotlin/blob/master/CHANGELOG.md>`__.
55
64
56
65
.. _kotlin-install-kotlin-multiplatform:
57
66
.. _kotlin-install-android:
@@ -72,32 +81,32 @@ Installation
72
81
73
82
.. tab:: Android
74
83
:tabid: android
75
-
76
- Add :file:`io.realm.kotlin`, specifying the library version and
77
- :file:`apply false`, to the list of plugins in your project-level Gradle
84
+
85
+ Add :file:`io.realm.kotlin`, specifying the library version and
86
+ :file:`apply false`, to the list of plugins in your project-level Gradle
78
87
build file, typically found at :file:`<project>/build.gradle`:
79
88
80
89
.. code-block:: kotlin
81
90
:caption: Global build.gradle
82
-
91
+
83
92
plugins {
84
93
id 'io.realm.kotlin' version '{+kotlin-sdk-version+}' apply false
85
94
}
86
-
95
+
87
96
Add the following to your app-level Gradle build file, typically
88
97
found at :file:`<project>/app/build.gradle`:
89
98
90
99
- Add :file:`io.realm.kotlin` to the list of plugins.
91
100
- Add the following to the list of dependencies:
92
-
101
+
93
102
- Add :file:`io.realm.kotlin:library-base` to the dependencies block.
94
103
- If using Device Sync in your application, add :file:`io.realm.kotlin:library-sync` to the dependencies block.
95
104
96
105
- To use coroutines with the SDK, add :file:`org.jetbrains.kotlinx:kotlinx-coroutines-core` to the list of dependencies.
97
106
98
107
.. code-block:: kotlin
99
108
:caption: Module build.gradle
100
- :emphasize-lines: 4, 12, 13, 14
109
+ :emphasize-lines: 4, 12-16
101
110
102
111
plugins {
103
112
id 'com.android.application'
@@ -110,84 +119,85 @@ Installation
110
119
}
111
120
112
121
dependencies {
113
- implementation 'io.realm.kotlin:library-base:{+kotlin-sdk-version+}'
114
- implementation 'io.realm.kotlin:library-sync:{+kotlin-sdk-version+}'// If using Device Sync
115
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}' // If using coroutines with the SDK
122
+ implementation 'io.realm.kotlin:library-base:{+kotlin-sdk-version+}'
123
+ // If using Device Sync
124
+ implementation 'io.realm.kotlin:library-sync:{+kotlin-sdk-version+}'
125
+ // If using coroutines with the SDK
126
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}'
116
127
}
117
128
118
129
.. tab:: Kotlin Multiplatform (KMP)
119
130
:tabid: kmp
120
131
121
- Add the following to your app-level Gradle build file, typically
122
- found at :file:`<project>/app/build.gradle`:
123
-
124
- - Add :file:`io.realm.kotlin` to the list of plugins.
125
- - Add the following to the list of dependencies:
126
-
127
- - Add :file:`io.realm.kotlin:library-base` to the dependencies block.
128
- - If using Device Sync in your application, add :file:`io.realm.kotlin:library-sync` to the dependencies block.
129
-
130
- - To use coroutines with the SDK, add :file:`org.jetbrains.kotlinx:kotlinx-coroutines-core` to the list of dependencies.
132
+ 1. Add the following to your app-level Gradle build file, typically found at :file:`<project>/app/build.gradle`:
131
133
132
- .. code-block:: kotlin
133
- :caption: Module build.gradle
134
- :emphasize-lines: 5, 18, 19, 20
134
+ - Add :file:`io.realm.kotlin` to the list of plugins.
135
+ - Add the following to the list of dependencies:
135
136
136
- plugins {
137
- kotlin("multiplatform")
138
- kotlin("native.cocoapods")
139
- id("com.android.library")
140
- id("io.realm.kotlin") version "{+kotlin-sdk-version+}"
141
- }
137
+ - Add :file:`io.realm.kotlin:library-base` to the dependencies block.
138
+ - If using Device Sync in your application, add :file:`io.realm.kotlin:library-sync` to the dependencies block.
142
139
143
- version = "1.0"
140
+ - To use coroutines with the SDK, add :file:`org.jetbrains.kotlinx:kotlinx-coroutines-core` to the list of dependencies.
144
141
145
- kotlin {
146
- android()
147
- iosX64()
148
- iosArm64()
142
+ .. code-block:: kotlin
143
+ :caption: App build.gradle
144
+ :emphasize-lines: 5, 18-22
145
+
146
+ plugins {
147
+ kotlin("multiplatform")
148
+ kotlin("native.cocoapods")
149
+ id("com.android.library")
150
+ id("io.realm.kotlin") version "{+kotlin-sdk-version+}"
151
+ }
149
152
150
- sourceSets {
151
- val commonMain by getting {
152
- dependencies {
153
- implementation("io.realm.kotlin:library-base:{+kotlin-sdk-version+}")
154
- implementation("io.realm.kotlin:library-sync:{+kotlin-sdk-version+}") // If using Device Sync
155
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}") // If using coroutines with the SDK
153
+ version = "1.0"
154
+
155
+ kotlin {
156
+ android()
157
+ iosX64()
158
+ iosArm64()
159
+
160
+ sourceSets {
161
+ val commonMain by getting {
162
+ dependencies {
163
+ implementation("io.realm.kotlin:library-base:{+kotlin-sdk-version+}")
164
+ // If using Device Sync
165
+ implementation("io.realm.kotlin:library-sync:{+kotlin-sdk-version+}")
166
+ // If using coroutines with the SDK
167
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:{+kotlinx-coroutines-version+}")
168
+ }
156
169
}
157
170
}
158
171
}
159
- }
160
172
161
- .. note:: Android Module Dependencies
162
-
163
- If you use any part of the SDK inside the Android module, add the
164
- SDK's compile-time dependency to your Android module :file:`build.gradle.kts`:
173
+ 2. If you use any part of the SDK inside the Android module, add the following compile-time dependencies to your module-level Gradle build file, typically found at :file:`<project>/module/build.gradle`:
165
174
166
175
.. code-block:: kotlin
167
- :copyable: false
176
+ :caption: Android Module build.gradle
168
177
169
178
dependencies {
170
179
compileOnly("io.realm.kotlin:library-base:{+kotlin-sdk-version+}")
171
180
}
172
-
173
181
// If using Device Sync
174
182
dependencies {
175
183
compileOnly("io.realm.kotlin:library-sync:{+kotlin-sdk-version+}")
176
184
}
177
185
178
- .. step:: Sync Gradle Files
186
+ .. step:: Sync Gradle Files
179
187
180
188
After updating the Gradle configuration,
181
189
resolve the dependencies by clicking :guilabel:`File` >
182
190
:guilabel:`Sync Project with Gradle Files` in the Android Studio menu bar.
183
191
You can now use the Kotlin SDK in your application.
184
192
193
+ .. _kotlin-supported-environments:
185
194
186
195
Supported Target Environments
187
196
-----------------------------
188
197
189
- Kotlin Multiplatform (KMP) supports a `wide range of application environments
190
- <https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets>`__.
198
+ Kotlin Multiplatform (KMP) supports a wide range of application environments
199
+ Refer also to Kotlin's `Multiplatform Gradle DSL reference: Targets
200
+ <https://kotlinlang.org/docs/multiplatform-dsl-reference.html#targets>`__ documentation.
191
201
192
202
Supported Environments
193
203
~~~~~~~~~~~~~~~~~~~~~~
@@ -239,3 +249,4 @@ The Kotlin SDK does *not* support the following environments:
239
249
- :file:`watchosSimulatorArm64`
240
250
- :file:`watchosX86`
241
251
- :file:`watchosX64`
252
+
0 commit comments