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
  • k

    Kweku

    04/08/2021, 11:57 PM
    What Testing libraries/ frameworks is everyone using?
    a
    t
    +7
    • 10
    • 24
  • g

    Grantas33

    04/09/2021, 1:45 PM
    Hey. Are the any best practices of porting an existing jvm library (that you do not own) to mpp? Should you: 1. Fork the jvm lib repo and split the code into jvm/common modules. Code your own platform-specific implementation in other platform (e.g. js) for code that could not be extracted to common. 2. Create a new mpp project. Depend on the jvm lib in the jvm module and wrap all of the jvm-specific lib functions/classes in your own wrapper functions/classes. Extract jvm lib common code to common module. Code your own platform-specific implementation in other platform (e.g. js). 3. Create a new mpp project. Depend on the jvm lib in the jvm module and wrap all of the functions/classes in your own wrapper functions/classes. This way common module will only contain code with
    expect
    keywords. Code your own platform-specific implementation /copy paste common implementation from jvm lib in other platform (e.g. js). I feel like option 1 is the cleanest, option 3 should allow for easiest updates whenever original jvm lib is updated and option 2 is the most balanced. What do you think?
    r
    • 2
    • 1
  • l

    Lena Brusilovski

    04/09/2021, 5:38 PM
    does anyone know how i can debug code that is written with kotlin on ios? when i run the code i cant seem to watch any variables, i get them as ObjcHeader or ObjcObject and i cant know the contents of them. Does anyone know how to fix it? if it is fixable?
    k
    • 2
    • 13
  • h

    Hossein Amini

    04/10/2021, 1:37 PM
    In KMM when I want to save data in sqldelight database on iOS, a KotlinException will be thrown while on Android it is Ok. How can I fix it?
    k
    k
    c
    • 4
    • 3
  • s

    spierce7

    04/11/2021, 3:04 AM
    Does anyone know of a multiplatform LRU Cache implementation?
    j
    • 2
    • 1
  • o

    okarm

    04/11/2021, 7:19 PM
    Edit: message was not related to multiplatform, removed to reduce visual clutter.
    e
    • 2
    • 3
  • a

    archana 0623

    04/12/2021, 6:19 AM
    Can anyone help me understand how can we handle asynchronous network calls with ktor http client like adding loader and when it is either success or error then hide it and load appropriate data, with promises and observables it could be done through success or error callback but how can we achieve the same with ktor http client?
    j
    • 2
    • 1
  • b

    Big Chungus

    04/12/2021, 10:40 AM
    I hope anyone from JB is here, as I've got a question. Are there any plans on supporting metadata-only libraries? The idea is to publish only commonMain output without any kotlin targets declared and being able to use it in any consumer project with arbitrary target set. Such artifact could only depend on other metadata-only libraries. EDIT: It'd be ideal to also allow dependencies on libraries with expect-actual for ALL kotlin targets (meaning metadata artifact from such dependencies covers all bases too, although I understand that this would be much harder to maintain) If not, it'd be nice to have an "exhaustive" gradle dsl target shortcut that registers all targets for the lib project.
    ➕ 15
    j
    s
    r
    • 4
    • 5
  • s

    sushma nayak

    04/12/2021, 1:16 PM
    How to fix "Test events were not received" in AS canary 14 for common module tests. I'm runnng it as Gradle run configuration.
    o
    • 2
    • 1
  • b

    bsimmons

    04/12/2021, 1:40 PM
    Is there an easy way to catch Java exceptions in multiplatform? I want to catch a specific
    <http://javax.net|javax.net>.ssl.SSLPeerUnverifiedException
    but I am only able to
    catch(e: <http://io.ktor.utils.io|io.ktor.utils.io>.errors.IOException){...}
    and nothing more specific than that. Any ideas?
    m
    • 2
    • 7
  • v

    Vitor Prado

    04/12/2021, 1:57 PM
    is there a way to store translations in common module?
    b
    p
    m
    • 4
    • 3
  • p

    Philip Dukhov

    04/12/2021, 3:38 PM
    Hi all! I’m trying to build a local annotation processor for my kotlin multiplatform module, and I’ve faced a couple of problems. 1. Cache looks not working at all in KMP common code. When I update annotation params or remove it, it doesn’t gets regenerated - actually I get old params in the
    process
    function. Only removing
    build/tmp/kapt3
    helps. If I use same annotation in my android target, this works fine. 2. In both cases (multiplatform/android modules) generated classes are not recognized by the AS - they are marked as
    Unresolved reference
    . But the build goes fine. My setup:
    annotations/build.gradle.kts
    plugins {
        kotlin("multiplatform")
        id("com.android.library")
    }
    
    kotlin {
        android()
        jvm()
        ios()
    }
    annotationProcessor/build.gradle.kts
    plugins {
        kotlin("multiplatform")
    }
    
    kotlin {
        jvm()
        sourceSets {
            val jvmMain by getting {
                dependencies {
                    implementation("com.squareup:kotlinpoet:1.8.0")
                    implementation(project(":annotations"))
                }
            }
        }
    }
    src/jvmMain/resources/META-INF/services/javax.annotation.processing.Processor
    file contains my processor
    shared/build.gradke.kts
    plugins {
        kotlin("multiplatform")
        kotlin("native.cocoapods")
        id("com.android.library")
        kotlin("kapt")
    }
    
    kapt {
        useBuildCache = false // even this didn't helped with the cash problem
    }
    
    kotlin {
        android()
        ios()
        cocoapods {
            this.frameworkName = "shared"
            summary = "shared"
            homepage = "-"
            license = "-"
        }
        sourceSets {
            val commonMain by getting {
                dependencies {
                    implementation(project(":modules:annotations"))
                    configurations["kapt"].dependencies.add(project(":modules:annotationProcessor"))
                }
            }
        }
    }
    Have anyone faced any of these?
    r
    m
    • 3
    • 7
  • b

    Bailey Pollard

    04/12/2021, 4:25 PM
    How do we execute code on a background thread in IOS using kotlin multiplatform?
    k
    • 2
    • 1
  • s

    sushma nayak

    04/12/2021, 7:01 PM
    Issue with running tests on KMM with coroutines-test. Included “org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.2-native-mt” in common tests. Gradle - gradle-6.8.2-bin.zip AS - Canary 9 Android gradle plugin version - 7.0.0-alpha09 Error in 🧵
    r
    j
    • 3
    • 10
  • j

    Josh

    04/12/2021, 7:52 PM
    anyone have experience with multiplatform livedata/observable packages? I built an app with moko mvvm and built out the android app with live data but apparently it doesnt work with swiftui
    j
    • 2
    • 2
  • j

    james

    04/13/2021, 4:37 PM
    Anyone have experience with using Mapbox with Kotlin Multiplatform?
    d
    m
    c
    • 4
    • 7
  • d

    Daniele B

    04/14/2021, 4:20 PM
    In the D-KMP sample landing page, I have added the instructions to write your own D-KMP app. You can build very quickly an app using: KMP, JetpackCompose and SwiftUI. Give it a go, and provide your feedback. We only grow by sharing! The main characteristics of the D-KMP Architecture: • it fully shares the ViewModel (and the DataLayer) • coroutine scopes are cancelled/reinitialized automatically, based on the current active screens and the app lifecycle (using LifecycleOwner on Android and the SwiftUI lifecycle on iOS) • it implements the MVI pattern and the unidirectional data flow • it implements the CQRS pattern, by providing 2 types of functions to the UI layer: Events and StateProviders • it uses Kotlin's StateFlow to trigger UI layer recompositions https://github.com/dbaroncelli/D-KMP-sample
    🔥 1
    👍 2
    👍🏽 1
    🙏🏻 1
    a
    • 2
    • 2
  • r

    Rita Okonkwo

    04/14/2021, 11:08 PM
    Hello everyone, I’m trying to run my KMM application (the android part) with Pixel 3 XL API 27 on my windows OS laptop , the build is successful but I can’t find the app in the emulator. Please has anyone encountered this before? If yes, please how was it fixed?
    h
    c
    • 3
    • 3
  • f

    Fabio Santo

    04/15/2021, 7:43 AM
    Hey everyone, is there any developer with Kotlin Multiplatform Mobile in Australia? 🇦🇺 I'd be keen to connect and share experiences! 👋 🙂
    d
    • 2
    • 21
  • n

    Neal Sanche

    04/15/2021, 11:34 PM
    Hi all, fairly new to KM, doing some GraphQL which requires an authorization header. The token is an ID token, basic JWT, nothing too fancy. Now, having trouble getting everything all initialized. We're going old-school and not using Koin or any DI, just making a top-level Kotlin object for the GraphQL apolloClient. I'll throw code in the thread.
    k
    c
    • 3
    • 8
  • h

    Hossein Amini

    04/16/2021, 11:23 AM
    How can I collect a flow in swift using KMM?
    m
    j
    m
    • 4
    • 4
  • r

    rocketraman

    04/16/2021, 2:25 PM
    Doing KMM with Compose on Android. Android Studio doesn't handle multiplatform well -- tests in shared code don't run properly, or resolve references. But IDEA Ultimate doesn't have a version of the Android Studio plugin needed for Compose. Anyone else having this issue and managed to work around it somehow?
    l
    c
    a
    • 4
    • 8
  • r

    Ryan Simon

    04/16/2021, 8:45 PM
    Hey all, quick question about
    kotlin.Result
    usage in KMP. trying to use it as a return type by using this in my
    :shared
    KMP module's build file
    kotlin {
        targets.all {
            compilations.all {
                kotlinOptions {
                    freeCompilerArgs = freeCompilerArgs + "-Xallow-result-return-type"
                }
            }
        }
    
        // other source sets and targets here...
    }
    I can build and run my apps just fine but the IDE is still highlighting that Result cannot be used as a return type. Anyone know if this is an IDE issue or I just didn't configure the build file correctly?
    k
    l
    • 3
    • 3
  • r

    robstoll

    04/18/2021, 9:37 AM
    how do you set
    sourceCompatibility = 8
    targetCompatibility = 8
    if you use
    jvm { withJava() }
    ?
    c
    t
    • 3
    • 3
  • s

    Se7eN

    04/18/2021, 8:05 PM
    What is this Unknown82 configuration? Every time I open the dropdown the number increases (like Unknown72, Unknown77, Unknown82)
    😄 1
    r
    s
    • 3
    • 2
  • n

    napperley

    04/18/2021, 10:44 PM
    How is the testing handled with the linuxArm32Hfp target on a Linux host alongside other Linux targets? Only binaries can be run on the linuxX64 target which covers Unit testing but the same can't be done with the linuxArm32Hfp target on a Linux X64 host, yet Gradle test tasks exist for the target 🤔.
    a
    • 2
    • 4
  • b

    Big Chungus

    04/19/2021, 3:08 PM
    Is there a particular reason why
    Closeable
    interface and use extension is not in the common stdlib?
    👍 1
    t
    l
    g
    • 4
    • 7
  • e

    eygraber

    04/20/2021, 4:31 AM
    I'm trying to setup common configuration between all of my modules (which all have the multiplatform plugin applied) in the root
    build.gradle.kts
    but I can't figure out how to do that. Any help?
    allprojects {
      repositories {
        google()
        mavenCentral()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
        maven("<https://s01.oss.sonatype.org/content/repositories/snapshots>")
      }
    
      // trying to do something like the following
      kotlin.sourceSets.all {
        languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
      }
    }
    e
    j
    +2
    • 5
    • 13
  • b

    Big Chungus

    04/20/2021, 7:44 AM
    Is it possible to build stuff for androidTV and wearOS with kotlin multiplatform?
    🙂 1
    j
    t
    • 3
    • 20
  • r

    Rita Okonkwo

    04/20/2021, 8:21 PM
    I have included my serialization dependency, but android studio says it’s an unresolved reference. I have invalidated caches and restarted but I’m still encountering same
    d
    c
    • 3
    • 7
Powered by Linen
Title
r

Rita Okonkwo

04/20/2021, 8:21 PM
I have included my serialization dependency, but android studio says it’s an unresolved reference. I have invalidated caches and restarted but I’m still encountering same
d

Dominaezzz

04/20/2021, 8:26 PM
build.gradle file pls
r

Rita Okonkwo

04/20/2021, 8:28 PM
Should I share a snapshot of the build.gradle file? @Dominaezzz
d

Dominaezzz

04/20/2021, 8:29 PM
yes
r

Rita Okonkwo

04/20/2021, 8:29 PM
I invalidated caches and restarted it again without clicking on configure kotlin and surprisingly the errors no longer show
👍 1
Thank you so much for your response
🙂 1
d

Dominaezzz

04/20/2021, 8:33 PM
You are very welcome. 🙂 :rubber_duck:
😁 3
c

Cicero

04/21/2021, 1:22 PM
Also, something that often works when crazy behaviors show up. Delete your auto generated folders and re-import the project. Android studio generates everything again.
👍 1
View count: 18