1

I am writing an experiment project for multi platform by using Kotlin. I wrote some common logic by using RXjava and retrofit. There are three folder Kotlin[commonMain] Kotlin[androidMain] Kotlin[iosMain]

The code work fine in Kotlin[androidMain] folder. When I moved in Kotlin[commonMain], Class unable to reslove retrofit and RX libraries.

Is it because Kotlin multi platform can not compile Rx and retrofit libs?

Or am I doing something wrong.

Please anyone can explain to me.

REgards,

**import okhttp3. unalbe to resolve***
**import okhttp3.Response unable to resolve**


class AuthorizationInterceptor(private val authorization: Authorization) : Interceptor{

    override fun intercept(chain: Interceptor.Chain): Response {
        var accessToken =  authorization.getCachedToken()
        val request: Request =
            chain.request().newBuilder().addHeader("Authorization", "%s ,  %s  , %s".format(accessToken))
                .build()
        return chain.proceed(request)
    }
}
user1154390
  • 2,331
  • 3
  • 25
  • 32
  • @Onik thanks, there is one module. module has three folders /flavour. Each flavour has own dependency. Dependency in build.gradle only works for mainandroid. Not for maincommon. – user1154390 Apr 12 '19 at 19:14

1 Answers1

0

That is correct. There is no variant of retrofit available (yet) for kotlin native. ktor-client is a very good alternate though.

This is a very nice article about a kotlin multi platform project and demonstrates ktor-client.

As for RxJava, as the name suggest, the framework is implemented for Java (and some JVM based languages) only. There are appreciable efforts in progress for kotlin-native such as RxKotlin/ Reaktive but nothing (widely acceptable) is production ready as yet.

farhanjk
  • 1,652
  • 16
  • 17