Questions tagged [kotlin-multiplatform]

Refers to Kotlin Multiplatform projects, aimed to share codebase between JVM, JS, Android, and Native

Filter by
Sorted by
Tagged with
102 votes
10 answers
166k views

Flutter & Android: Your build is currently configured to use Java 17.0.2 and Gradle 7.0.2

I got this on my android part of Flutter. Unsupported Java. Your build is currently configured to use Java 17.0.2 and Gradle 7.0.2. Possible solution: - Open Gradle wrapper settings, change `...
Punreach Rany's user avatar
86 votes
2 answers
126k views

Check your module classpath for missing or conflicting dependencies [closed]

I have a project with Java and Kotlin, which I am able to successfully run and build. However, when I open the project in IntelliJ, I see the same error in many of the project files. The error is &...
MadLax's user avatar
  • 1,239
36 votes
1 answer
6k views

Kotlin Multiplatform Mobile targetSdk deprecated

I set up my build.gradle.kts file in the shared module of my KMM project like the following snippets shows: android { namespace = "com.my.project" compileSdk = 33 sourceSets[&...
J. Hegg's user avatar
  • 1,673
25 votes
3 answers
42k views

Generate UUID on kotlin-multiplatform?

Are there any kotlin-multiplatform common functions to get a UUID/GUID? // ideally something like this val newUUID = UUID() // "1598044e-5259-11e9-8647-d663bd873d93" println("newUUID = $newUUID") ...
Veener's user avatar
  • 4,971
25 votes
0 answers
2k views

Is there anyway we can create flavored versions of Kotlin Multiplatform build files like dev and prod?

I have a requirement where I want to have different set of data to be shipped with the library generated by kotlin multiplatform module for different flavors like dev and prod. In an Android project, ...
Paresh Dudhat's user avatar
22 votes
2 answers
5k views

@Parcelize in multi-platform project

I'd like to create a class in a multi-platform project, and use Parcelize to make it Parcelable in the Android version. So in my lib-common project, I tried: expect annotation class Parcelize() ...
Cactus's user avatar
  • 27.4k
20 votes
5 answers
9k views

Sqldelight database schema not generated

I have a KMM project and want to use SqlDelight library, but when I build the project database schema not generated and table entities also. actual class DatabaseDriverFactory(private val context: ...
Jemo Mgebrishvili's user avatar
20 votes
1 answer
6k views

How to convert Kotlin ByteArray to NsData and viceversa

Fighting with a Kotlin Multiplatform project I have ended with the problem of needing to work with NsData on my iOS platform from the sharedModule working with Kotlin Native. Because of this, I need ...
Francisco Durdin Garcia's user avatar
20 votes
4 answers
22k views

Handling Exception in HttpClient Ktor

I have written a common code in a common module as below and tested in JS environment val response = client.post<HttpResponse>(url) { body = TextContent("""{"a":1,"b":2}""", ContentType....
andylamax's user avatar
  • 1,978
19 votes
3 answers
10k views

Listen to Kotlin coroutine flow from iOS

I have setup a Kotlin Multiplatform project and attached a SQLDelight database to it. Its all setup and running correctly as i have tested it on the android side using the following: commonMain: ...
Wazza's user avatar
  • 1,775
19 votes
3 answers
8k views

Is there a way to use Firebase (Authentication) with Kotlin Multiplatform?

I have a project which uses Firebase Authentication in Android. It works well and I want to port the same project to an iOS App using code sharing with Kotlin Multiplatform. I initially thought I ...
Archie G. Quiñones's user avatar
17 votes
4 answers
4k views

Using kapt with multiplatform subproject

I have the following project structure root-project │ build.gradle.kts │ └───multiplatform-project │ │ build.gradle.kts │ │ │ └───src │ │ kotlin | | js │ └───simple-...
Egor Okhterov's user avatar
17 votes
1 answer
1k views

How to Implement Custom Cache Mechanism with Kotlin Multiplatform(Android, iOS) Ktor Client

I am working on Kotlin Multiplatform Project. I used Ktor Client for Network calls. I want to cache some request based on some custom logic not based on response header. HttpCache feature provided ...
Randheer's user avatar
  • 1,044
16 votes
2 answers
5k views

Kotlin Multiplatform Configuration issue

I continue getting Gradle configuration error in my KMP + Jetpack Compose project A problem occurred configuring project ':shared'. Configuration with name 'testApi' not found. My setup is: Android ...
Андрій Пугач's user avatar
16 votes
9 answers
20k views

"No transformation found: class io.ktor.utils.io.ByteChannelNative" error using Ktor

I'm trying to fetch and deserialize some data that is being hosted on github. { "Meals": [ { "id": "1598044e-5259-11e9-8647-d663bd870b02", "name&...
Gareth Miller's user avatar
16 votes
2 answers
673 views

KMM: Compilation failed: Unexpected IrType kind: KIND_NOT_SET

I'm trying to run tests in the shared library. Setup (versions should be the same for both machines - all are up to date as of today): Kotlin 1.6.21 (tried 1.6.20 and 1.6.10) OpenJDK 11.0.15 (via ...
peter.o's user avatar
  • 3,500
16 votes
0 answers
5k views

SourceSet with name 'jvmMain' not found

I'm trying to run kotlin multiplatform project with jvm and js source sets but am getting the following error: FAILURE: Build failed with an exception. * Where: Initialization script '/private/var/...
Marcel Bro's user avatar
  • 4,977
15 votes
3 answers
9k views

File IO with Kotlin multiplatform

I would like to do some basic filesystem operations on mingwX64 Windows (and possibly other platforms): open, close, read, rename, get metadata, list files in a directory. I have found one project ...
Ford O.'s user avatar
  • 1,464
15 votes
5 answers
4k views

Kotlin Multiplatform: How to mock objects in a unit test for iOS

I'm working on a Kotlin-multiplatform (KMP) library for iOS / Android. I have written some unit tests for JVM, for which I use MockK to create spies and mocks, but MockK doesn't support Kotlin native ...
Abel's user avatar
  • 1,367
15 votes
1 answer
3k views

What's the different between native-mt and normal kotlin coroutine lib?

When we use coroutine, we can either have the normal kotlin coroutine or the native-mt version. i.e. implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0' or implementation '...
Elye's user avatar
  • 57.3k
15 votes
1 answer
5k views

How to fix 'The feature "multi platform projects" is experimental and should be enabled explicitly' warning in IntelliJ IDEA

Whenever I write an expect function in IntelliJ IDEA, I get the following warning: The feature "multi platform projects" is experimental and should be enabled explicitly Where can enable ...
binarynoise's user avatar
14 votes
5 answers
6k views

How to configure an iOS Application for Kotlin Multiplatform in Android Studio?

I want to add a Run/Debug Configuration for an iOS Application for a Kotlin Multiplatform Mobile application in Android Studio 4.1.2. However, there seems to be a problem with the configuration for ...
Jan Deinhard's user avatar
  • 19.9k
13 votes
8 answers
11k views

KMM project setup with cocoaPods fails on first compile

I created a new KMM project and selected Cocoapods for the iOS framework distribution and as soon as it finished building it threw the following error: Executing of 'pod install' failed with code 1. ...
barryalan2633's user avatar
13 votes
2 answers
8k views

Kotlin Multiplatform : Plugin [id: 'com.android.library'] was not found

I am trying to set up Android Library via Kotlin Multiplatform Library. I am getting error: Plugin [id: 'com.android.library'] was not found in any of the following sources: Please help me by ...
Alex's user avatar
  • 488
13 votes
2 answers
6k views

Spaces in test method names when targeting multiplatform

I really love the ability of Kotlin to add spaces to method names, which is a well-documented approach commonly used to make test names more readable: In tests (and only in tests), it's acceptable ...
Steven Jeuris's user avatar
13 votes
2 answers
3k views

Kotlin Multiplatform Mobile: How to handle errors (network, db, etc.) in iOS?

I have this function that makes a network request and writes results to SQLDelight database: @Throws(Exception::class) suspend fun updateData() In iOS project in Xcode I see that this function is ...
Marat's user avatar
  • 6,491
13 votes
1 answer
832 views

How to read file with okio inside commanMain module in a Kotlin Multiplatform Project?

I am trying to read/write files in the commonMain module. I created a new Kotlin Multiplatform App for Android and iOS using the Android Studio Wizard. (New -> New Project ... -> Koltin ...
Sven's user avatar
  • 1,758
13 votes
0 answers
359 views

Kotlin multiplatform 'Go to declaration' goes to decompiled code

When using using Android Studio's 'Go to declaration' feature (cmd + click), a decompiled source is shown, when though the source is in my project. The kotlin MP source is in another module. I can ...
Patrick Jackson's user avatar
13 votes
2 answers
11k views

Kotlin Multiplatform Mobile unable to run on iOS: Execution failed for task ':shared:compileKotlinIosX64'

I have created fresh project(Hello World) in KMM followed by their official website. In android it works smooth but when I am trying to run in XCode it's giving errors because of which I am unable to ...
Fatin Wasta's user avatar
12 votes
6 answers
15k views

Kotlin Multi Platform default project error running iOs App: could not resolve com.android.tools.build:gradle:7.4.0-rc01

I created a default KMP project, and changed nothing. It runs fine on android, but when I try to run it on iOS it tells me that it cant find the gradle plugin: A problem occurred configuring root ...
Siavash's user avatar
  • 7,743
12 votes
3 answers
3k views

Kotlin multiplatform: Accessing build variables in code

I'm working on a Kotlin Multiplatform project which is an SDK providing functionality for iOS & Android applications. In our build.gradle.kts we have a couple of variables that we would like to ...
amadeus's user avatar
  • 133
12 votes
3 answers
6k views

Use Gradle sub-projects with Kotlin multiplatform

I'm using Kotlin multi-platform (JVM & JS), which in IDEA creates three projects: demo, demo-js and demo-jvm. I would like to split the common code into more subprojects/submodules. Let's say I ...
Mark's user avatar
  • 19.4k
12 votes
4 answers
4k views

Is there multiplatform lock in Kotlin?

What multiplatform Lock or synchronization approach should be used in multiplatform Kotlin code? Previously in Java code i used synchronized and i can see synchronized in Kotlin too. However it's ...
4ntoine's user avatar
  • 20.1k
12 votes
4 answers
7k views

Is there a way in Kotlin Multiplatform to format a float to a number of decimal places?

Most of the answers use Java (e.g. String.format) to get the job done, but I need a way to do this purely with Kotlin to support multiplatform programming. This means not using java.* standard ...
anabi's user avatar
  • 267
12 votes
3 answers
3k views

Kotlin Multiplatform Project Unit Test Issue

Today I just updated my Android Studio to Android Studio 3.5.2 Build #AI-191.8026.42.35.5977832, built on October 31, 2019 JRE: 1.8.0_202-release-1483-b49-5587405 x86_64 JVM: OpenJDK 64-Bit Server VM ...
alvinWB's user avatar
  • 143
11 votes
4 answers
4k views

Cannot locate tasks that match ':composeApp:compileJava' as task 'compileJava' is ambiguous in project ':composeApp'

Cannot locate tasks that match ':composeApp:compileJava' as task 'compileJava' is ambiguous in project ':composeApp'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac'...
Devendra Singh's user avatar
11 votes
2 answers
3k views

How to determine build type in kotlin-multiplatform project

I’m working on a multiplaform project, iOS and JVM (I’m not targeting Android directly). Depending on the build type (debug or release) I want to configure the logging level (i.e. to print only errors ...
Diego Palomar's user avatar
11 votes
4 answers
13k views

Ktor: Serialize/Deserialize JSON with List as root in Multiplatform

How can we use kotlin.serialize with Ktor's HttpClient to deserialize/serialize JSON with lists as root? I am creating the HttpClient as follows: HttpClient { install(JsonFeature) { ...
Patrick Jackson's user avatar
11 votes
2 answers
9k views

Gradle sync failed: Unsupported method: KotlinPlatformContainer.supports()

I just updated Android Studio to the latest version 3.5.1 and I know get the following error: Gradle sync failed: Unsupported method: KotlinPlatformContainer.supports(). The version of Gradle you ...
Benjamin's user avatar
  • 7,210
11 votes
2 answers
5k views

Execution failed for task ':shared:podInstall'

I am very new to KMM (Kotlin Multiplatform Mobile) and iOS development (including CocoaPods). I have come across the following build error in Android Studio. Execution failed for task ':shared:...
user15134436's user avatar
11 votes
6 answers
5k views

Kotlin MPP expect / actual with different signatures

I have a manager class that has an Android and iOS impl (from a 3rd party lib). "ex. MyManagerImpl()". To construct the 3rd party manager, iOS does not require a Context but Android does. I ...
Maurycy's user avatar
  • 3,951
11 votes
3 answers
2k views

Kotlin Multiplatform library for iOS with bitcode

we use Kotlin to share a library between Android and iOS. We set up everything, but on iOS i need Bitcode enabled. After a research I found solution: kotlin { targets { fromPreset(presets.jvm, '...
Vario's user avatar
  • 520
11 votes
1 answer
2k views

Multi-platform InputStream Alternative in Kotlin?

I’m looking for a multi-platform alternative to input streams. My concrete task is to fetch an encrypted file from a remote server via https and decrypt it on demand. In Java land I would an ...
wollnyst's user avatar
  • 1,833
11 votes
1 answer
5k views

Multiplatform error when building iosApp: Command PhaseScriptExecution failed with a nonzero exit code

I am working on a multiplatform app in Kotlin on Android Studio and when I try to run the app to an iOS simulator, I get this error: The following build commands failed: PhaseScriptExecution [CP-User]...
Christopher Mathews's user avatar
11 votes
1 answer
3k views

How to share Java code between Android and JVM targets (with Kotlin Multiplatform)?

I am trying to share Java code between Android and JVM targets using Kotlin Multiplatform feature (sample project: https://github.com/dmitrykolesnikovich/accessJavaCode-issue) Simply saying, ":...
Dmitry Kolesnikovich's user avatar
11 votes
1 answer
6k views

How to do Unit Testing in Kotlin/Native Multiplatform?

I have follow the tutorial of https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html and I wanted to Unit testing the commonTest I created in the SharedModule. Things I tried: I had tried ...
Cheeseburger's user avatar

1
2 3 4 5
38