https://kotlinlang.org logo
Docs
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
  • z

    zsperske

    06/09/2020, 12:17 AM
    is anyone here familiar with using KodeIn in their multiplatform projects?
    k
    k
    • 3
    • 2
  • z

    zalewski.se

    06/09/2020, 6:35 AM
    I’m having an KMP project with many kmp modules inside, I’m facing weird behavior when I edit something in module
    A
    , the changes aren’t reflected directly in another module
    B
    that consumes it. Also when I try to navigate from
    B
    to
    A
    it takes me to the
    .jar
    file of this module. Has anyone had similar problems?
    ➕ 3
    m
    l
    • 3
    • 7
  • t

    Theo

    06/09/2020, 11:16 AM
    anyone worked with C inerop on both iOS and Android through KMP? are there some docs or something I can follow?
    g
    t
    • 3
    • 6
  • b

    bsimmons

    06/09/2020, 12:07 PM
    Is there a way to run .java tests in a kotlin MPP? I am trying to test that my Java interop interfaces are correct. (Things like @JvmStatic @JvmOverloads.) I can't seems to get them running in jvmTests directory. Perhaps I should just add tests to a separate Java project?
    k
    • 2
    • 2
  • p

    pardom

    06/09/2020, 1:44 PM
    I would use that set to filter this:
    targets {
        presets
            .filterIsInstance<AbstractKotlinNativeTargetPreset<*>>()
            .filter { it in supportedTargets }
            .forEach { preset ->
                targetFromPreset(preset, preset.name) {
                    compilations["main"].source(sourceSets["nativeMain"])
                    compilations["test"].source(sourceSets["nativeTest"])
                }
            }
    }
    r
    k
    • 3
    • 5
  • a

    Alexander Larsson

    06/09/2020, 2:36 PM
    What is the best practice for testing common code on Android? In my Kotlin MPP the
    allTests
    task runs tests only on iOS (specifically a task called
    iosSimTest
    ). If you write Android specific tests they run on android successfully by running the task called
    testDebugUnitTest
    . I cannot figure out how to run the common test cases on Android. Am I supposed to run them on JVM and it is not possible to run on Android? I currently do not have a JVM target set up since it is an iOS/Android project only.
    • 1
    • 1
  • a

    akapanina

    06/09/2020, 3:26 PM
    Hi folks! I’m Anastasiia, product manager in Kotlin Multiplatform team and I have a funny question for you today 🙂 Have you had cases when strict memory model in Kotlin/Native actually helped you find potential (or real) bugs in Kotlin/JVM part of your Multiplatform project? If yes - please, leave ➕ reaction under that message. I’d like to ask you a couple of questions about your case in direct messages. Thanks! p.s. If you’d like to share your story in thread - it’s fine too 🙂
    🤔 5
    🇳🇴 1
    👀 3
    k
    r
    +3
    • 6
    • 11
  • p

    pardom

    06/09/2020, 5:53 PM
    I’m splitting out a KMP project into multiple feature/layer modules and perhaps I don’t have my Gradle dependencies setup correctly, but dependencies seem pretty slow to update. For example, in the graph
    A
    ->
    B
    ->
    C
    Changing an interface in
    C
    isn’t reflected in
    A
    or
    B
    as in a JVM project. Some combination of reimporting, invalidating, etc will get it working again, but I haven’t narrowed down the correct workflow. Has someone experienced and/or solved this?
    👀 2
    z
    l
    • 3
    • 2
  • m

    Mananpoddarm

    06/10/2020, 8:16 AM
    Hi everyone. I am using kotlin multiplatform to generate android libraries. what is the best way to debug it though. Currently, I have to build the .jar file, put it in the android app and run the android app to see the log statements. Is there any better way to do it?
    k
    a
    • 3
    • 3
  • e

    Elka

    06/10/2020, 11:00 AM
    Hello, having Android studio IDE errors but builds are working fine.  Here's the structure: Repository1 is composed of • Android module
    :library
    • A Kotlin MP module targeting iOS and Android.
    :core
    . • The Android module
    :library
    is dependent on
    :core
    . In
    build.gradle (library)
    , I added
    api project(":core")
    to the dependencies. Repository2 is composed • Android App
    :app
    • Common Kotlin MP module targeting iOS and Android
    :common
    • The
    :app
    is dependent on
    :library
    . In
    build.gradle (app)
    I added
    implementation linkto:Library
    • The
    :common
    module is dependent only on
    :core
    . In
    build.gradle (common)
    I added
    api linkto:core
    . The build works fine but I am getting this IDE error: "Cannot access class X, Check your module classpath for missing or conflicting dependencies". X is a class in
    :core
    Any idea on how to solve this as the IDE errors are very annoying... Kotlin 1.3.72
    l
    • 2
    • 4
  • m

    Mananpoddarm

    06/10/2020, 3:38 PM
    I am not able to load files using File() from java.io in my kotlin multiplatform project. It compiles fine but when I include the build .aar file in my android project, it gives no such directory exists error. Is it not possible to load a file in a KMP project?
    c
    • 2
    • 2
  • b

    Brandon Saunders

    06/10/2020, 4:27 PM
    I've seen some open discussion on it but not a clear yes or no answer. Does Kotlin built using a gradle file support conditional compilation? We're investigating using this technique, https://medium.com/dont-code-me-on-that/aspect-oriented-programming-in-kotlin-95ff8598913, for supporting annotations that will allow us to do simple call count mocking for some of our objects but we want to make sure that that code is not present in either JS, Android or iOS code on release builds.
    • 1
    • 1
  • e

    edenman

    06/11/2020, 1:49 AM
    Trying to upgrade coroutines so i can use StateFlow stuff and getting a
    Unresolved reference: MutableStateFlow
    compile error in my kmp module. Anybody else seen this? The IDE resolves it no problem
    • 1
    • 6
  • k

    Kurt Renzo Acosta

    06/11/2020, 10:11 AM
    Hello! Is anyone encountering issues when using
    combine
    on flows with K/N? My code works on Android but on iOS it doesn't run the
    combine
    block. Any help would be greatly appreciated!
    t
    • 2
    • 3
  • n

    Nick

    06/11/2020, 12:46 PM
    Hey good morning everyone. I just started a new job. Their codebase is written entirely in Java. The have several shared Java libraries, which are used for the iOS (using j2objc), Desktop and Android apps. I’d like to slowly begin converting these to Kotlin. Is it possible to create a Multiplatform project and import the old Java project(s) into it? Or is there a better solution?
    j
    d
    t
    • 4
    • 6
  • b

    Brandon Saunders

    06/11/2020, 7:42 PM
    Is there an example anywhere of using source annotationRetentions in a multiplatform project? I'm trying to follow this, https://medium.com/@elye.project/annotation-tutorial-for-dummies-in-kotlin-1da864acc442, but it presumes a non-multiplatform project and i'm running into a wall where my annotation module needs to be multiplatform but the processor module can likely not be. When you do that though you get the warning stating that the java processor module can't depend on the android annotation one.
    h
    y
    h
    • 4
    • 12
  • a

    Alexander Larsson

    06/12/2020, 8:19 AM
    Does anyone know if there is a recommended way to unit test SQLDelight common code on Android? You need an android context for the sql driver. Should I use instrumented unit tests or Roboelectric? Is there some other better way?
    j
    s
    p
    • 4
    • 5
  • j

    janvladimirmostert

    06/13/2020, 7:14 AM
    what version of kotlin serialization should i be using with Kotlin 1.4-M2? I've got 1.4-M2 for the plugin and 0.20.0 for the common, jvm and js part, but it's failing to compiling saying it can't find kotlinx import
    plugins {
        val kotlinVersion = "1.4-M2"
        kotlin("multiplatform") version kotlinVersion
        kotlin("plugin.serialization") version kotlinVersion
    }
    val serializationVersion = "0.20.0"
    
            val commonMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                    implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion")
                }
            }
    
            ...
    
            val jsMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-js"))
                    implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion")
                }
            }
    import kotlinx.serialization.json.Json
    import kotlinx.serialization.json.JsonConfiguration    
    
    fun main() {
        val json = Json(JsonConfiguration.Stable)
        val jstring = json.toJson(Test.serializer(), Test(blah = 3))
        println(jstring.toString())
        ...
    h
    • 2
    • 2
  • r

    Rohit Singh

    06/13/2020, 7:44 AM
    hi guys I am new to kmp I am trying to work on a sample project, I was planning to use coroutines. I need to understand how can I implement
    <http://dispatchers.io|dispatchers.io>
    in iosMain. 🙏
    c
    • 2
    • 5
  • a

    andylamax

    06/13/2020, 2:34 PM
    The KMP gradle plugin doesn't support jetpack compose. Any work around apart from using the id("kotlin-android")?
    z
    c
    +2
    • 5
    • 7
  • v

    Venkat , Bangalore , India

    06/14/2020, 3:26 PM
    Hi All, m new to KMP, facing some issue... I have used expect/actual classes... but when i extracted the generated aar for android, the actual class is missing, i still see expect class in the classes.jar... Not sure what i am missing.. Appreciate if someone can help me?
    j
    • 2
    • 2
  • d

    Davide Giuseppe Farella

    06/14/2020, 5:25 PM
    Is there a way to automatically fix names for Js? Like
    fun `hello world`()
    I have to set
    @JsName
    manually
    a
    • 2
    • 3
  • a

    Andrew

    06/14/2020, 7:15 PM
    For implementing a date object in KMP is the best solution so far to make a "expect class" with full implementation on each platform?
    e
    s
    r
    • 4
    • 8
  • s

    Slackbot

    06/14/2020, 7:41 PM
    This message was deleted.
    g
    • 2
    • 1
  • g

    GarouDan

    06/14/2020, 8:49 PM
    Hi, Do you know if we have something like
    System.getenv()
    jvm method but that works for
    js
    and
    native
    as well?
    m
    • 2
    • 10
  • j

    Justin

    06/15/2020, 2:48 AM
    Cross-posting: https://kotlinlang.slack.com/archives/C19FD9681/p1592189294056000
    r
    • 2
    • 1
  • a

    Andrew

    06/15/2020, 5:41 AM
    When trying to run unit tests in IntelliJ it says "no tasks available". A solution I found was to set the tests to run with IntelliJ instead of gradle. This runs them but now its failing to load resources from the ClassLoader which is needed for some of the tests. When I run the tests via gradle script it appears to work properly. Does any of this sound like known issues, any workarounds? Trying to convert a jvm library to KMP but need to get the basics working before doing any major refactors to more into common.
    s
    • 2
    • 1
  • a

    aleksey.tomin

    06/15/2020, 7:34 AM
    @e5l I try to move my OSX project to 1.4-M2 and 1.3-1.4-M2 With this code
    val kotlinVersion = "1.4-M2"
        val ktorVersion = "1.3.2-1.4-M2"
        sourceSets {
            commonMain {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                    implementation("io.ktor:ktor-client-core:${ktorVersion}")
        }.  }.  }
    I have error
    e: Could not find "io.ktor:ktor-io-cinterop-bits" in [/Users/atomin/Documents/iq/xpoint-sdk, /Users/atomin/.konan/klib, /Users/atomin/.konan/kotlin-native-prebuilt-macos-1.4-M2/klib/common, /Users/atomin/.konan/kotlin-native-prebuilt-macos-1.4-M2/klib/platform/macos_x64].
    I try to add
    val macosMain by getting {
                dependencies {
                    implementation("io.ktor:ktor-client-core:${ktorVersion}")
                }
            }
    but nothing was changed. I try to fix something like https://github.com/ktorio/ktor/issues/943
    macosX64("macos") {
            binaries.all {
                linkerOpts = mutableListOf("-L/usr/local/opt/curl/lib", "-I/usr/local/opt/curl/include/curl", "-lcurl")
            }
        }
    but error still active.
    $ ls /usr/local/opt/curl/lib
    libcurl.4.dylib	libcurl.a	libcurl.dylib	pkgconfig
    $ ls /usr/local/opt/curl/include/curl
    curl.h		curlver.h	easy.h		mprintf.h	multi.h		stdcheaders.h	system.h	typecheck-gcc.h	urlapi.h
    e
    • 2
    • 8
  • a

    Alexander Larsson

    06/16/2020, 8:27 AM
    Hey, anyone know of a way to detect if you are running your tests on Android device or JVM?
    a
    • 2
    • 5
  • s

    Siggi Gunnarss

    06/16/2020, 9:42 AM
    Hello all. Does anyone have a link to a large gradle android/ios mpp project? Most samples are rather small. I'm looking for something that has multiplatform modules depending on other multiplatform modules?
    h
    j
    r
    • 4
    • 7
Powered by Linen
Title
s

Siggi Gunnarss

06/16/2020, 9:42 AM
Hello all. Does anyone have a link to a large gradle android/ios mpp project? Most samples are rather small. I'm looking for something that has multiplatform modules depending on other multiplatform modules?
h

Hamza

06/16/2020, 9:43 AM
Unsure if this uses other modules, but feel free to check this out https://github.com/JetBrains/kotlinconf-app
s

Siggi Gunnarss

06/16/2020, 10:07 AM
Thanks, this is a good example, although there are no complex module dependencies
j

Jurriaan Mous

06/16/2020, 11:05 AM
I have a for now internal project which will at some moment be opened up and works with multiple layers of multiplatform dependencies. Is there anything specific you want to know? An example of a module depending on a different module in same project. I abstracted each platform setting into its own .gradle file so I avoid duplication.
plugins {
    id("kotlin-multiplatform")
}

apply {
    from("../gradle/common.gradle")
    from("../gradle/js.gradle")
    from("../gradle/jvm.gradle")
    from("../gradle/native.gradle")
    from("../gradle/publish.gradle")
}

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                api(project(":yaml"))
            }
        }
        commonTest {
            dependencies {
                implementation(project(":testmodels")) {
                    // Workaround for: <https://youtrack.jetbrains.com/issue/KT-33712>
                    exclude(module = "core")
                }
            }
        }
    }
}
s

Siggi Gunnarss

06/16/2020, 1:13 PM
That's very helpful, thanks. The platform gradle abstraction makes a lot of sense. So you only have to reference api(:yaml) in commonMain source sets, not nativeMain etc.?
j

Jurriaan Mous

06/16/2020, 1:15 PM
Only commonMain, just like you do with the recent multiplatform dependencies. Kotlin multiplatform gradle plugin takes care of the rest.
👍 1
In the past there were issues with transitive project dependencies but that all got fixed along the way 🙂 https://youtrack.jetbrains.com/issue/KT-28019
r

russhwolf

06/16/2020, 1:45 PM
Maybe not comolex enough, but here's a small project with two layers of common dependencies https://github.com/russhwolf/multiplatform-hello
👍 1
View count: 4