In side the SharedCode module, I’m not able to import java.
In the app module, I’m able to import java. The JDK location had been provided in project structure, shown in screenshot below. What am I missing?
You cannot use Java code inside the iOS source set (iosMain), the only place where you could use Java code (in your case) is in the Android source set (androidMain), everywhere else you can only use Kotlin
I’m trying test a http request.
URL provided here URL - Kotlin Programming Language
It doesn’t allow me to add dependencies in the SharedCode Build.gradle.
Any workaround so the iosMain can have more functions to use?
If you want to use something in iOS you need to look for classes that are available either in Common or in Native (blue dot or purple dot respectively)
Following this example: https://ktor.io/clients/http-client/multiplatform.html
I have added the suggested implementation to Build.gradle for SharedCode… Only the one for Android works.
Import io.ktor in the android main is ok.
For common and iosMain does not work. Please see screenshots.
Hello @shophk If you target is doing a http request I recomend to you don’t use a actual class on iOS, instead of this you Can make the request on a common class with ktor that can work for both platforms.
However if you can doing on iOS you import the ktor implementation on iOS target from your common gradle.