# Multiplatform Project: iOS and Android cannot import ktor in SharedCode module

**URL:** <https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236>\
**Category:** Native\
**Created:** [June 27, 2019, 9:49am UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236 "2019-06-27T09:49:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shophk](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shophk](https://discuss.kotlinlang.org/u/shophk)\
**Post date:** [June 27, 2019, 9:49am UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/1 "2019-06-27T09:49:25Z")

</div>

I’m following this [https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html](https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html)  
Its about Multiplatform Project: iOS and Android

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?  
 ![10%20PM](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/f/f1dbd3d3825d5380fea065446d302b05d1f6a03c.png)  
 ![17%20PM](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/e/eb324afccece3aeb08afe325923c672162e6dc47.png)

---

<div class="post-metadata">

**Author:** ![SackCastellon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sackcastellon/32/4553_2.png) [@SackCastellon](https://discuss.kotlinlang.org/u/SackCastellon)\
**Post date:** [June 27, 2019, 11:54am UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/2 "2019-06-27T11:54:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shophk](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shophk](https://discuss.kotlinlang.org/u/shophk)\
**Post date:** [June 27, 2019, 2:11pm UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/3 "2019-06-27T14:11:06Z")

</div>

I’m trying test a http request.  
URL provided here [URL - Kotlin Programming Language](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.url/-u-r-l/index.html)  
It doesn’t allow me to add dependencies in the SharedCode Build.gradle.  
Any workaround so the iosMain can have more functions to use?

![58%20PM](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/3/3fb9957d0a1e8d84be862782f39fa6faf3228fcc.png)

---

<div class="post-metadata">

**Author:** ![SackCastellon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sackcastellon/32/4553_2.png) [@SackCastellon](https://discuss.kotlinlang.org/u/SackCastellon)\
**Post date:** [June 27, 2019, 6:21pm UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/4 "2019-06-27T18:21:40Z")

</div>

> [@shophk](#):
>
> URL provided here [https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.url/-u-r-l/index.html](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.url/-u-r-l/index.html?_ga=2.204361241.880625983.1559263646-763892890.1532721151)

That class is only available for **JavaScript** targets.

 ![20190627_201905](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/3/323cd8c15e1639810ed3598c4a34d48a9bc52c89.jpeg)

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)

Now, for making HTTP requests you could use Ktor ([https://ktor.io/clients/index.html](https://ktor.io/clients/index.html))

---

<div class="post-metadata">

**Author:** ![shophk](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@shophk](https://discuss.kotlinlang.org/u/shophk)\
**Post date:** [June 28, 2019, 6:58am UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/5 "2019-06-28T06:58:26Z")

</div>

Following this example:  
[https://ktor.io/clients/http-client/multiplatform.html](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.

 ![00%20PM](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/6/651f904074a5077b7cdd01699f6f1a3da428f0ae.png)

![10%20PM](https://us1.discourse-cdn.com/flex019/uploads/kotlinlang/original/2X/e/ecdab2183b89e8d5a20fd68022059209e4482e90.png)

I found these examples [GitHub - ktorio/ktor-samples: Sample projects for Ktor](https://github.com/ktorio/ktor-samples) but there is no example showing what I’m trying to do.

---

<div class="post-metadata">

**Author:** ![SackCastellon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sackcastellon/32/4553_2.png) [@SackCastellon](https://discuss.kotlinlang.org/u/SackCastellon)\
**Post date:** [June 28, 2019, 8:19am UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/6 "2019-06-28T08:19:54Z")

</div>

🤔 Now I don’t really know why it isn’t working.

---

<div class="post-metadata">

**Author:** ![guillodacosta](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@guillodacosta](https://discuss.kotlinlang.org/u/guillodacosta)\
**Post date:** [September 18, 2019, 6:09pm UTC](https://discuss.kotlinlang.org/t/multiplatform-project-ios-and-android-cannot-import-ktor-in-sharedcode-module/13236/7 "2019-09-18T18:09:28Z")

</div>

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.

```auto
kotlin {
    sourceSets {
        iosMain {
            dependencies {
                implementation "io.ktor:ktor-client-ios:$your_ktor_version"
            }
        }
    }
}

```
