https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
multiplatform
  • k

    Kris Wong

    05/03/2019, 8:35 PM
    I notice when I run unit tests from Android Studio for an Android app with a Kotlin MPP subproject, the class path is incorrect, which causes it to not find the classes from the subproject. included in the classpath is: <subprojectdir>/build/classes/kotlin/main and <subprojectdir>/build/classes/kotlin/test. the classes are in the build directory at <subprojectdir>/build/classses/kotlin/jvm/main.
    • 1
    • 1
  • n

    Nikky

    05/03/2019, 10:04 PM
    i am looking for a library to establish a longliving 2-way connection between client and server on jvm and js clients i originally thought ktor would work for websockets but websocket support is only on CIO, which is only on the jvm it seems
    d
    • 2
    • 2
  • s

    serebit

    05/05/2019, 3:58 AM
    Imports for same-module internal objects in my common test source set are showing up as red in IntelliJ, but Gradle is running the tests perfectly fine. Is this a known issue? (
    kotlin-multiplatform
    plugin, version
    1.3.31
    )
    l
    l
    • 3
    • 2
  • g

    galex

    05/05/2019, 4:27 AM
    I have an issue with ktor-client on iOS, where I get the following error:
    kotlin.NotImplementedError: An operation is not implemented: Obtaining serializer from KClass is not available on native due to the lack of reflection. Use .serializer() directly on serializable class.
            at 0   mu51k-ios                           0x0000000108ff28a5 kfun:kotlin.Error.<init>(kotlin.String?)kotlin.Error + 21
            at 1   mu51k-ios                           0x00000001090f8bd5 kfun:kotlin.NotImplementedError.<init>(kotlin.String)kotlin.NotImplementedError + 21
            at 2   mu51k-ios                           0x0000000109134802 kfun:kotlinx.serialization.compiledSerializer@kotlin.reflect.KClass<#GENERIC_kotlin.Any>.()Generic + 226
            at 3   mu51k-ios                           0x00000001091342c1 kfun:kotlinx.serialization.serializer@kotlin.reflect.KClass<#GENERIC_kotlin.Any>.()Generic + 97
            at 4   mu51k-ios                           0x000000010913e9b0 kfun:kotlinx.serialization.modules.getContextualOrDefault@kotlinx.serialization.modules.SerialModule.(kotlin.reflect.KClass<#GENERIC_kotlin.Any>)Generic + 144
            at 5   mu51k-ios                           0x000000010913dbf8
    It’s weird because the type response the API returns is indeed registered:
    actual val networkHttpClient: HttpClient
        get() = HttpClient {
            install(JsonFeature) {
                serializer = KotlinxSerializer().apply {
                    setMapper(CheckEmailResponse::class, CheckEmailResponse.serializer())
                    setMapper(AuthResponse::class, AuthResponse.serializer())
                    setMapper(ActionResponse::class, ActionResponse.serializer())
                }
            }
        }
    Does this error mean the http-client doesn’t know what to do with String? Are we supposed to register simple types ourselves?
    l
    s
    • 3
    • 9
  • s

    Shameek Sarkar

    05/06/2019, 10:04 AM
    Is it possible to use Channels from iOS in a multiplatform project? Or anything equivalent to a rx stream?
    j
    k
    +2
    • 5
    • 9
  • h

    hudsonb

    05/06/2019, 11:01 PM
    Are there any examples of a MPP consisting of only common code? I've got a set of classes that I'd like to release as a MPP (with multiple target platforms), with no platform specific code
    s
    • 2
    • 1
  • v

    vmichalak

    05/07/2019, 3:04 PM
    During my Kotlin MPP (Android / iOS) build i have a strange issue during the 'linkTestDebugExecutableIos' task. (more info in reply to this post) Do you have an idea to correct this?
    s
    h
    g
    • 4
    • 10
  • s

    Simon Schubert

    05/07/2019, 10:38 PM
    I really like that every Android code example was in Kotlin and not Java so far
    l
    • 2
    • 2
  • b

    basher

    05/08/2019, 3:50 AM
    Is there a way to have a multiplatform project depend on another and have both projects’ binaries be included in the same iOS app?
    y
    • 2
    • 3
  • r

    Ruckus

    05/08/2019, 1:30 PM
    (MPP newbie here, so if there's a resource I'm missing that answers my questions, please let me know) Is there no way to have a default method implementation in an expect class?
    expect class Grade : Comparable<Grade> {
        val rough: Int
        val fine: Int
    
        // Apparently I can't implement this here
        override fun compareTo(other: Grade) {
            var result = rough.compareTo(other.rough)
            if (result == 0) result = fine.compareTo(other.fine)
            return result
        }
    }
    r
    • 2
    • 4
  • m

    Marc Knaup

    05/08/2019, 1:40 PM
    Why is a different extension function called depending on whether one is
    expect
    or not? common module:
    sealed class Test {
    	object A : Test()
    }
    If I don't use `expect`:
    fun Test.print() {
    	when (this) {
    		is Test.A -> print() // calls method below
    	}
    }
    
    fun Test.A.print() { // gets called
    	println("A")
    }
    If I use `expect`:
    fun Test.print() {
    	when (this) {
    		is Test.A -> print() // recursive call
    	}
    }
    
    expect fun Test.A.print() // not called
    l
    • 2
    • 2
  • m

    max.denissov

    05/08/2019, 1:45 PM
    is there any approach to create mock object in tests of the common module for android/ios project? Tried to use Mockk, but common tests fails while run building common ios code, but passes while run building common android code.
    t
    r
    • 3
    • 3
  • m

    Marc Knaup

    05/08/2019, 5:52 PM
    Did anybody manage to publish a multiplatform project to Sonatype? 🤔
    A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact fluid-stdlib-metadata:jar.asc:asc:null, trying to add MavenArtifact fluid-stdlib-metadata:jar.asc:asc:null
    (same here, unanswered: https://stackoverflow.com/questions/54318156/kotlin-multiplatform-library-project-upload-issue-pom-multiple-artifacts) configuration: https://github.com/fluidsonic/fluid-library/blob/master/sources/FluidLibraryVariantConfiguration.kt#L168
    l
    a
    • 3
    • 24
  • b

    basher

    05/08/2019, 6:52 PM
    Has anyone run into
    Declaration annotated with '@OptionalExpectation' can only be used in common module sources
    recently? I've found old SO posts saying it's fixed. It just started happening on my machine for an
    @SharedImmutable
    in our common sources, for a declaration that has been in our codebase building fine for awhile now. Using 1.3.31
    l
    • 2
    • 7
  • a

    altavir

    05/09/2019, 12:29 PM
    I am struggling a lot with gradle-metadata feature. I have a module (this one: http://npm.mipt.ru:8081/artifactory/webapp/#/artifacts/browse/tree/General/gradle-dev-local/hep/dataforge/dataforge-meta) which is compiled and deployed with
    enableFeaturePreview("GRADLE_METADATA")
    . And then I have a library which is also build with gradle meta. According to documentation, all I need is to declare it in the
    commonMain
    block of mpp, and I will automatically get dependencies for all branches. It does not work. I have to write platform-specific dependencies for all platforms and additional metadata for common. What am I doing wrong?
    m
    l
    • 3
    • 26
  • j

    Jan Stoltman

    05/10/2019, 9:50 AM
    Is there any alternative for Mockk which supports K/N?
    🇳🇴 2
    t
    • 2
    • 2
  • k

    Kris Wong

    05/10/2019, 8:14 PM
    has anyone seen a crash running unit tests for an iOS app after bringing in a Kotlin MPP via pods? libc++abi.dylib: terminating with uncaught exception of type NSException
    o
    • 2
    • 8
  • t

    tylerwilson

    05/11/2019, 6:02 PM
    I am attempting to include an mp project in an Android app in Android Studio via the settings.gradle include and project().projectDir mechanism. Unfortunately, I can find the right incantation to have it build just the jvm/android lib/jar needed by the app. I have tried starting with an IDEA MP project and adding the Android library stuff, and also from a vanilla AS generated library and adding the kotlin-multiplatform plugins. But I have not been able to do it. My goal is to have the common shared lib in one repo, which is referenced from all the Android and iOS apps. Anybody get anything like this working? Please?
    s
    • 2
    • 4
  • m

    Mohammadsss1

    05/13/2019, 2:04 AM
    Any tutorial about converting an MPP's gradle from Groovy to Kotlin in Android studio without breaking the build process! I have renamed the files by adding .kts to the end of build.gradle file and .settings file but keeps didn't go well!
    r
    o
    • 3
    • 4
  • r

    ribesg

    05/13/2019, 9:12 AM
    I’m trying to run some tests on a MPP library (Android & iOS targets) and I have some questions. 1. Why do I need to have JUnit/JUnit5/TestNG on the Android part just to get the
    @Test
    annotation? 2. Can you have top-level tests instead of having to put them in a class? 3. Is there a good sample on how to have tests running for iOS, especially in the case of needing some CInterops?
    ➕ 1
    s
    r
    • 3
    • 12
  • a

    Andy Victors

    05/13/2019, 12:42 PM
    Does anyone have a working example of using
    ktor
    in MPP environment, specifically on iOS where currently only Main-Thread Dispatcher is offered (https://github.com/Kotlin/kotlinx.coroutines/issues/462)?
    j
    r
    +3
    • 6
    • 41
  • j

    Jan Stoltman

    05/13/2019, 1:22 PM
    Hey guys, does anybody know how to make mockk
    any
    matcher match objects of one specific class? I imagine something like this:
    any<MyClass::class>()
    l
    d
    • 3
    • 3
  • r

    ribesg

    05/14/2019, 1:07 PM
    Why aren’t
    main
    dependencies added to the corresponding
    test
    sourceSet automatically? I need to duplicate all dependencies defined in
    commonMain
    in
    commonTest
    if I want to use them. Same for
    androidMain
    and
    androidTest
    . I didn’t test it, but I suppose it’s the same for iOS
    g
    l
    • 3
    • 4
  • b

    basher

    05/14/2019, 3:38 PM
    Congrats @kpgalligan on getting the Obj-C/Swift generics improvements merged 🎉 https://github.com/JetBrains/kotlin-native/pull/2850
    😍 7
    🔥 6
    🎉 31
    💯 12
    s
    k
    +3
    • 6
    • 5
  • u

    uhe

    05/15/2019, 8:55 AM
    I'm having trouble setting up
    kotlinOptions
    in a multiplatform lib project. As per the docs I added this to the
    kotlin
    section in the lib's `build.gradle`:
    targets.all {
            compilations.all {
                kotlinOptions {
                    suppressWarnings = true // just to see if it's applied
                }
            }
        }
    But it does not work (warnings are still displayed in the IDE). Anybody else having issues with these compiler options? I'm using IntelliJ Idea 2019.1.2 and gradle 5.1.1
    a
    • 2
    • 3
  • j

    Jan Stoltman

    05/15/2019, 9:16 AM
    Hey guys, I would like to add another (non default) test sourceset/compilation for android and ios to my project. Is there any example of how such a thing can be done? The official documentation is not very helpful
    a
    • 2
    • 2
  • o

    o.semen

    05/15/2019, 11:00 AM
    Hi, I’m trying to build iOS project of my MPP but it fails with this error
    > Task :app:cinteropFirebaseIos UP-TO-DATE
    > Task :app:linkDebugFrameworkIos
    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_FIRDatabase", referenced from:
          objc-class-ref in combined.o
    ld: symbol(s) not found for architecture x86_64
    e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    
    > Task :app:linkDebugFrameworkIos FAILED
    i
    m
    • 3
    • 12
  • p

    pablisco

    05/16/2019, 10:06 AM
    Is it possible to do Parameterised tests on Kotlin Multiplatform? The testing documentation is very limited and looking at the source I can’t find anything there
    🍿 1
    r
    r
    • 3
    • 9
  • p

    pardom

    05/16/2019, 4:22 PM
    Are
    actual
    implementations restricted to the
    expect
    declaration module?
    h
    • 2
    • 2
  • b

    Benjamin Charais

    05/16/2019, 6:49 PM
    Hello all, I’ve been working on building a multi platform project for Kotlin to support multiple android and ios apps in a single project. I have had some success in accomplishing this, my projects will build happily so that is quite exciting for me. Now I have come to the situation where in my IntelliJ I am attempting to use the
    actual
    keyword on a class to implement an expect. IntelliJ gives me the warning:
    The feature "multi platform projects" is experimental and should be enabled explicitly
    I have found that in IntelliJ there would be an expectation under :
    Preferences -> 
      Build, Execution, Deployment ->
        Kotlin Compiler ->
          Additional command line parameters:
    To add the flag
    -Xmulti-platform
    I am driving my project settings from gradle and found I can include this block for my subprojects:
    targets.all {
        compilations.all {
            kotlinOptions {
                freeCompilerArgs += '-Xmulti-platform'
            }
        }
    }
    I am still getting the error and it does not seem to have any effect in the IDE understanding that the feature has been adjusted. Am I missing something obvious here? Did I implement my gradle wrong?
    g
    • 2
    • 6
Powered by Linen
Title
b

Benjamin Charais

05/16/2019, 6:49 PM
Hello all, I’ve been working on building a multi platform project for Kotlin to support multiple android and ios apps in a single project. I have had some success in accomplishing this, my projects will build happily so that is quite exciting for me. Now I have come to the situation where in my IntelliJ I am attempting to use the
actual
keyword on a class to implement an expect. IntelliJ gives me the warning:
The feature "multi platform projects" is experimental and should be enabled explicitly
I have found that in IntelliJ there would be an expectation under :
Preferences -> 
  Build, Execution, Deployment ->
    Kotlin Compiler ->
      Additional command line parameters:
To add the flag
-Xmulti-platform
I am driving my project settings from gradle and found I can include this block for my subprojects:
targets.all {
    compilations.all {
        kotlinOptions {
            freeCompilerArgs += '-Xmulti-platform'
        }
    }
}
I am still getting the error and it does not seem to have any effect in the IDE understanding that the feature has been adjusted. Am I missing something obvious here? Did I implement my gradle wrong?
Took me a while but I finally found my answer. In the individual app build gradle (Specifically for android… we’ll see about other modules) I had to add
buildTypes {
        all {
            kotlinOptions {
                freeCompilerArgs = [
                       '-Xmulti-platform',
                       '-Xuse-experimental=kotlin.Experimental'
                ]
            }
        }
}
Tried this in many other places to no avail.
g

gildor

05/16/2019, 11:23 PM
I don't think that -Xuse-experimental for Experimental annotation makes any sense for your case
b

Benjamin Charais

05/16/2019, 11:59 PM
It was for another reason, I just forgot to remove it. Thanks though
g

gildor

05/17/2019, 12:15 AM
What kind Gradle plugin do you use? Because I don't remember such warning if you use recommended kotlin-multiplatform Gradle plugin
b

Benjamin Charais

05/17/2019, 4:15 PM
I am using the kotlin-multiplatform plugin. That’s why it’s so confusing to me. I was able to sort out all of my issues before ending my day yesterday, and now have a fully building multiplatform project.
g

gildor

05/17/2019, 4:25 PM
Maybe you have this warning in some module that doesn't use MPP plugin? But not 100% sure that this warning is not present if you use MPP plugin
View count: 3