You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
13. In the `app/build.gradle.kts` file, set the `android.defaultConfig.minSdk` value to 24.
207
+
14. Sync the Gradle files as suggested by the IDEor using the **File** | **SyncProject with GradleFiles** menu item.
208
+
209
+
You can find the resulting state of the project in the [shared_module](https://github.com/Kotlin/kmp-integration-sample/tree/shared_module) branch of the GitHub repository.
93
210
94
211
If you want to better understand the layout of the resulting project, see [basics of KotlinMultiplatform project structure](https://kotlinlang.org/docs/multiplatform-discover-project.html).
95
212
@@ -98,27 +215,22 @@ If you want to better understand the layout of the resulting project, see [basic
98
215
To use cross-platform code in your Android application, connect the shared module to it, move the business logic code
99
216
there, and make this code cross-platform.
100
217
101
-
1. In the `shared/build.gradle.kts` file, ensure that `compileSdk` and `minSdk` are the same as those in
102
-
the `app/build.gradle.kts` config of your Android application.
103
-
104
-
If they're different, update them in the `shared/build.gradle.kts` file. Otherwise, the compiler will report
105
-
the version mismatch as an error.
106
-
107
-
2. Add a dependency on the shared module to the `app/build.gradle.kts` file:
218
+
1. Add a dependency on the shared module to the `app/build.gradle.kts` file:
108
219
109
220
```kotlin
110
221
dependencies {
222
+
// ...
111
223
implementation(project(":shared"))
112
224
}
113
225
```
114
226
115
-
3. Synchronize the Gradle files by clicking **Sync Now** in the notification.
227
+
2. Sync the Gradle files as suggested by the IDEor using the **File** | **SyncProject with GradleFiles** menu item.
116
228
117
229

118
230
119
-
4. In the `app/src/main/java/` directory, open the `LoginActivity.kt` file in the `com.jetbrains.simplelogin.androidapp.ui.login`
231
+
3. In the `app/src/main/java/` directory, open the `LoginActivity.kt` file in the `com.jetbrains.simplelogin.androidapp.ui.login`
120
232
package.
121
-
5. To make sure that the shared module is successfully connected to your application, dump the `greet()` function
233
+
4. To make sure that the shared module is successfully connected to your application, dump the `greet()` function
122
234
result to the log by adding a line to the `onCreate()` method:
123
235
124
236
```kotlin
@@ -130,12 +242,12 @@ there, and make this code cross-platform.
130
242
// ...
131
243
}
132
244
```
133
-
6. Follow Android Studio's suggestions to import missing classes.
134
-
7. In the toolbar, select `app` from the dropdown and click **Debug**{width=20}.
245
+
5. FollowAndroidStudio's suggestions to import missing classes.
246
+
6. In the toolbar, select `app` from the dropdown and click **Debug** {width=20}.
135
247
136
248
{width="300"}
137
249
138
-
8. On the **Logcat** tab, search for `Hello` in the log, and you'll find the greeting from the shared
250
+
7. On the **Logcat** tab, search for `Hello` in the log, and you'll find the greeting from the shared
139
251
module.
140
252
141
253
{width="700"}
@@ -358,7 +470,7 @@ Connect your framework to the iOS project manually:
358
470
> ```
359
471
>
360
472
> {style="tip"}
361
-
473
+
362
474
6. Build the project in Xcode. If everything is set up correctly, the project will build successfully.
363
475
364
476
> If you have a custom build configuration different from the default `Debug` or `Release`, on the **Build Settings**
@@ -387,7 +499,7 @@ Connect your framework to the iOS project manually:
387
499
}
388
500
}
389
501
```
390
-
502
+
391
503
3. Run the app from Xcode to see the result:
392
504
393
505
{width=300}
@@ -413,11 +525,11 @@ Connect your framework to the iOS project manually:
413
525
}
414
526
}
415
527
```
416
-
528
+
417
529
6. Run the Xcode project to see that the iOS app shows the login form. Enter "Jane" for the username and "password" for the password.
418
530
The app validates the input using the shared code:
0 commit comments