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

    Slackbot

    09/18/2021, 11:12 AM
    This message was deleted.
    :not-kotlin: 1
    e
    • 2
    • 2
  • m

    Mike

    09/20/2021, 10:10 AM
    Hi, I’m using Kotlin multiplatform in one of my iOS projects. I need to write several features which will run in the background while the app is not running (main thread is not allowed in background tasks, the OS will silently kill the task if it tries to use main thread), these include things like background tasks, widgets, etc. I’ve been running into problems with kotlin multiplatform code crashing due to the current memory model and I’ve been investigating. Has anyone been able to successfully use kotlin multiplatform for background tasks on iOS?
    b
    • 2
    • 5
  • h

    Hadji Musaev

    09/20/2021, 11:16 AM
    Hi guys! I wanted to discuss this topic: https://youtrack.jetbrains.com/issue/KT-30878 I wanted to write a small library that would contain some business logic which should be shared across a service, an Android app and an iOS app. I can compile it separately for Java and Android, but I’m struggling to find the best way to structure the project in such a way that would allow me to build 3 different artifacts from the same code base. Has anyone had to solve a similar problem?
    j
    u
    • 3
    • 13
  • f

    Forrest Pangborn

    09/20/2021, 7:46 PM
    has anyone had trouble including
    kotlinx-atomicfu
    as a
    common
    dependency? i tried for awhile to include
    0.16.3
    as such for awhile today with the artifact specified in the project
    README
    . it claims the gradle plugin approach can be avoided if intended use is just within a
    common
    sourceset, but i couldn't get it to work unless i used a different artifact name. didn't work:
    org.jetbrains.kotlinx:atomicfu-common
    worked:
    org.jetbrains.kotlinx:atomicfu
    • 1
    • 1
  • b

    brabo-hi

    09/20/2021, 8:47 PM
    Hi, is there a kmm library for storing settings for both android/ios ?
    t
    • 2
    • 2
  • b

    brabo-hi

    09/20/2021, 9:13 PM
    how should we handle BigDecimal and monetary values in KMM ?
    e
    m
    • 3
    • 5
  • a

    Amritansh

    09/20/2021, 10:23 PM
    Hi, I am getting this when I try to build
    ./gradlew :shared:build
    my KMM project
    Task :shared:compileKotlinMetadata FAILED
    and in the stacktrace I am getting this
    Unresolved reference: newSingleThreadContext
    . I am using kotlin : 1.5.31 and coroutines version
    1.5.2-native-mt
    . Any idea what might be the issue? I had to comment out
    #kotlin.mpp.enableGranularSourceSetsMetadata=true
    #kotlin.native.enableDependencyPropagation=false
    in the gradle.properties since sql delight does not support hmpp. can that be the issue here?
    k
    r
    +2
    • 5
    • 8
  • j

    jean

    09/21/2021, 9:06 AM
    I’m trying to tesmsqldelight code the same way it is done there : https://github.com/touchlab/KaMPKit/blob/main/shared/src/commonTest/kotlin/co/touchlab/kampkit/SqlDelightTest.kt but I get the following error. Any idea what I’m doing wrong?
    kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
    o
    o
    l
    • 4
    • 9
  • s

    Sebastian Oßner

    09/21/2021, 9:53 AM
    Hi there people, I am looking into the use of KMM for our company, but I am unsure what amount of work that would entail. We currently use J2Objc to convert our (quite large) stack to ObjC and build a Framework out of that. Our Android application is quite small, mainly using existing Java libraries that at some point interface with C++ libraries via JNI. The main point of the application is to connect to devices on the network and transmit vast amounts of data (but everything is already handled in the underlying libraries) Basically the question is if simply switching from J2ObjC to KMM seems feasible (without too much overhead)
    t
    t
    • 3
    • 9
  • b

    Borja

    09/21/2021, 1:39 PM
    Hi there. I’m trying to use an objc library through cinterop but it crashes on run time with message
    dyld: Library not loaded:
    Does anyone had the same issue? I built a minimum repro repo here: https://github.com/flaquir4/MinimumRepro
    b
    • 2
    • 4
  • s

    sushma nayak

    09/21/2021, 4:43 PM
    I use kotlinxserialization 1.2.2 and use
    ignoreUnknownKeys = true
    . Still get the error ERROR -
    Use 'ignoreUnknownKeys = true' in 'Json {}' builder to ignore unknown keys.
    My json config -
    Json {
        isLenient = true
        ignoreUnknownKeys = true
        prettyPrint = true
      }
    m
    • 2
    • 2
  • s

    Scott Kruse

    09/21/2021, 7:50 PM
    Any know of any projects / articles w/ kmp with native target + flutter front end?
    o
    k
    • 3
    • 5
  • m

    mkrussel

    09/21/2021, 8:40 PM
    After installing Xcode 13, I can no longer create the interop libraries for my framework generated from the Xcode. I've got building the framework as a dependency of the interop task in gradle. This worked before when I was using an Xcode 12.x release. It's an Objective-C framework. The error message is just that it could not build the module.
    /var/folders/qt/q46m5kx100j30g9hdl4rzf_h0000gn/T/16722905496877169974.m:1:9: fatal error: could not build module 'PangeaMapView'
    Does Kotlin not support outputs from Xcode 13? Are there any logs with more detailed information about the failure? I'm on Kotlin 1.5.21 to work with Jetpack Compose.
    👀 1
    m
    • 2
    • 2
  • m

    MarkRS

    09/22/2021, 8:44 AM
    Anyone else seeing https://github.com/kotlin-hands-on/kmm-networking-and-data-storage/issues/9 "again"? Seems to have happened here after the latest kotlin plugin update. None of the fixes I can find seems to fix it.
    s
    • 2
    • 1
  • n

    Nicolas Verinaud

    09/22/2021, 10:59 AM
    [RESOLVED ✅] Hi ! I am writing a shared interface with a suspend function. In iOS it generates a protocol with a method with a completionHandler which is great. Problem is how can I handle cancellation ? My shared interface :
    interface CanRetrieveAuthorizationToken {
        suspend fun getToken(): String
    }
    The corresponding protocol :
    public protocol CanRetrieveAuthorizationToken {
       
        /**
         @note This method converts instances of CancellationException to errors.
         Other uncaught Kotlin exceptions are fatal.
        */
        func getToken(completionHandler: @escaping (String?, Error?) -> Void)
    }
    ✅ 1
    m
    • 2
    • 10
  • j

    Justin

    09/22/2021, 5:44 PM
    [KMP Pattern Question] I am building a design system library that will be consumed by Android, iOS, macOS, and Web. The library will vend everything from primitives (e.g. colors/gradients/fonts/etc.) to controls (e.g. buttons/selectors/text fields/etc.). Simple enough. Here's where things got thorny: This app also needs to specialize the appearance of everything based on a
    theme
    , which is a global appearance setting (you can think of it sort of like light/dark mode) that is only known at runtime. In other words, this library needs to return everything from
    Color.primary
    to
    FloatingActionButton()
    (for example) based on the runtime-determined
    theme
    of the app. The theme doesn't change across the app lifecycle (i.e. we know right at init what the theme will be and it's a constant for the rest of that app instance's existence), which is helpful. What I'm struggling with is where this
    theme
    setting should live. All of the components in this design system library will need to be able to read this value to work correctly, so I can imagine having it be a global var that consumers can set on the library itself. But when I attempt to build something like this:
    interface Theme {
        companion object {
            var value: Theme = DefaultTheme()
        }
    }
    
    class DefaultTheme(...): DefaultTheme {...}
    ...I see the following warning in the console:
    w: Theme.kt: With old Native GC, variable in singleton without @ThreadLocal can't be changed after initialization
    And I'd generally like to avoid stored mutable state with my K/N libraries if at all possible. Would love to hear peoples' thoughts on the most idiomatic/safest approach to this!
    k
    p
    • 3
    • 15
  • j

    Jim

    09/22/2021, 8:44 PM
    👋 is there something akin to
    @JsName
    and
    @JVMName
    for native? Accessing the resulting classes from c++ is pretty unpleasant
    <http://kotlin.com|kotlin.com>.jim.blah.Blah
    . If there isn’t I’m considering putting a shim in my native source set at the top right under kotlin so at least it would be
    kotlin.Blah
    . Am I missing something here? Thanks!
    ➕ 1
    s
    l
    • 3
    • 6
  • h

    hallvard

    09/22/2021, 8:57 PM
    One of my JvmTests complains that some parameters to a constructor are missing. This is for an expect/actual class with 9 parameters in the constructor, but only the first three are needed, since the last 6 default to null. But the null values are set in the
    expect
    declaration, since
    actual
    functions cannot have default argument values. I have the
    @JvmOverloads
    annotation in the actual implementation (Idea warns me it has no effect since there are no default arguments), and also tried to include it in the expect implementation (no warning from Idea), but to no avail. So my test doesn't compile and cannot run ... What did I miss?
    • 1
    • 1
  • g

    Gene Cahill

    09/23/2021, 5:34 PM
    How do I set up release / debug variants for android in a multiplatform project?
    l
    • 2
    • 1
  • s

    saket

    09/24/2021, 4:18 AM
    After updating to AGP, Xcode is failing to build my project because gradle is unable to read
    JAVA_HOME
    variable. It seems like Xcode doesn’t source any shell profile during its build process causing
    JAVA_HOME
    to resolve to
    null
    . I checked this by adding this to my `build.gradle`:
    println("JAVA_HOME = ${System.getenv("JAVA_HOME")}")
    Folks who’re using AGP 7.0, have any of you run into this before?
    m
    • 2
    • 6
  • m

    Michal Klimczak

    09/24/2021, 8:16 AM
    I have a small but annoying issue. I have a monorepo for android and ios app and a shared module that is built into xcframework with
    gradle :shared:assembleSharedDebugXCFramework
    . This gradle comand is run as a Build Phase in xcode and the framework is embedded via framework search paths. Reproducing issue: 1. Change sth in shared module code. 2. Run build in xcode (takes a lot of time because xcframework is fully rebuilt). 3. The change is applied, everything fine. ✅ 4. Run build in xcode without changing anything (quick, the xcframework is not rebuilt fully). This step is crucial, without it the changes are applied just fine. 5. Change sth in shared module code again. 6. Run build in xcode (takes a lot of time because xcframework is fully rebuilt). 7. The change is not applied ‼️ 8. Run build in xcode without changing anything (quick, the xcframework is not rebuilt fully). 9. Only now the change is applied. ✅ I would rather say it's an xcode issue, but not sure. It's like in pt.7 the xcode built the framework but somehow didn't pick it yet. Only the next time. I think I had sth similar with regular frameworks and
    packForXcode
    but not 100% sure.
    • 1
    • 2
  • f

    FadiBouteraa

    09/24/2021, 12:48 PM
    Hi #kmm help me plz Undefined symbols for architecture arm64: "_OBJC_CLASS_$_SharedLoginPayload", referenced from: objc-class-ref in LoginViewModel.o
    m
    • 2
    • 10
  • i

    ivano

    09/24/2021, 7:06 PM
    There was a library to convert swift ui to compose but is not updated anymore. How is that possible if we could convert swift ui then kotlin would eat flutter for breakfast
    c
    • 2
    • 2
  • r

    Robert

    09/25/2021, 7:36 AM
    Any clue how to fix this in intellij 2021.2?
    This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2020.3.1 or newer.
    j
    j
    j
    • 4
    • 9
  • a

    avinash sai pavan munnangi

    09/26/2021, 9:33 AM
    Hi all, Im new to KMM and Im trying to hit the api and get the data using coroutines. it is working fine in android facing issues in ios . can anyone help me
    y
    m
    • 3
    • 4
  • r

    Rohan Maity

    09/26/2021, 11:20 AM
    Hello, I am working on Multiplatform project targeting
    android, iOS and Web
    For the web app somehow my generated JS file is getting blocked
    The resource was blocked due to MIME type ("text/html") mismatch (X-Content-Type-Options: nosniff).
    I have just done the simple
    Hello world
    only, Its working on android and iOS has anyone encountered the same issue ? Any help here would be appreciated More info in replies
    c
    • 2
    • 6
  • r

    robjperez

    09/27/2021, 11:10 AM
    Hey there!, I’m having some trouble when using a cocoapods dep in the ios build, It was working well and now I’m suspecting that xcode new version has messed up something. I’m getting
    Exception in thread "main" java.lang.Error: /var/folders/0d/4r7ddycs7msfghjht2w29hdw0000gq/T/12354154991012977801.m:1:9: fatal error: could not build module 'Foo'
            at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:192)
            at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
            at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
            at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:531)
            at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268)
            at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
            at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
            at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
            at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
    in the interop task
    :sdk:cinteropFooIosArm64
    It is very hard to get any clue with that error 😞
    v
    p
    • 3
    • 5
  • t

    Tarika Chawla

    09/27/2021, 2:43 PM
    Hi all, Anyone has any experience integrating a KMM in a Development Pod in iOS instead of the project itself? I was able to import the KMM in the development pod by adding it through podspec file but hitting a roadblock when I call those functions.
    l
    • 2
    • 20
  • j

    jimmyt

    09/27/2021, 4:53 PM
    I'm working on a KMM project targeting iOS and Android, and occasionally when I try to edit the KMM module's build.gradle.kts file, the entire thing lights up with "Unresolved reference" errors. At the time of my last commit, the project had no errors. Now, even though build.gradle.kts is completely unchanged from my last commit, it has 48 "Unresolved reference" errors, most of which are on basic keywords like "implementation" and "sourceSets". Any idea what could be causing this?
    f
    h
    +4
    • 7
    • 10
  • m

    MarkRS

    09/28/2021, 10:14 AM
    Suddenly all over my code I'm getting red lines complaining "The feature 'multi platform project' is experimental and should be enabled explicitly", even directly underneath the annotation @ExperimentalMultiplatform. I've now added the compiler option -Xmulti-platform (via gradle, I use AS), but I still get the red lines. Despite this the app builds and runs, although it crashes immediately, perhaps with a related error but I'm still tracking that down.
    l
    e
    e
    • 4
    • 7
Powered by Linen
Title
m

MarkRS

09/28/2021, 10:14 AM
Suddenly all over my code I'm getting red lines complaining "The feature 'multi platform project' is experimental and should be enabled explicitly", even directly underneath the annotation @ExperimentalMultiplatform. I've now added the compiler option -Xmulti-platform (via gradle, I use AS), but I still get the red lines. Despite this the app builds and runs, although it crashes immediately, perhaps with a related error but I'm still tracking that down.
l

louiscad

09/28/2021, 1:05 PM
Can you pinpoint the last commit where you didn't have the issue and inspect what changed since then?
m

MarkRS

09/28/2021, 1:30 PM
Good thought. Yes I can and yes I will 🙂
e

Etienne

10/27/2021, 10:15 PM
@MarkRS I have the same issue in my (brand new) project, did you find a fix?
m

MarkRS

10/28/2021, 10:14 AM
I don't have this issue any more @Etienne, but I'm sorry to say I don't know what I did that fixed it 😞 . Does your code run? I suspect it was something in build files (or is that too obvious to even say?). I do still have red lines everywhere, import statements complaining about not finding io.ktor and similar, but again the code builds and runs. @ephemient pointed out that "plugins don't work in KMM", which seems too much of a blanket statement, but it does seem to me that they perhaps "don't work" to the extent of preventing ktlint seeing some thing.
e

Etienne

10/28/2021, 12:26 PM
Yah my code ran/runs, after mucking about for a whole day, I found that the latest Bumblebee AS 'fixes' the issue. I tried everything I could find/think of on the Chipmunk AS release, no dice.
I'll try to find a place to report the issue that makes sense. Doesn't seem like Jetbrains thinks its on their end, from the issues I found being closed and all. Maybe it's one of those "AS uses older components and it'll eventually be fixed" type deals.
e

ephemient

10/28/2021, 7:42 PM
https://youtrack.jetbrains.com/issue/KT-27683 more like "plugins that aren't built for MPP, don't work with MPP" than "plugins don't work"
View count: 6