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

    dazza5000

    03/18/2020, 2:06 PM
    I get this error
    r
    d
    • 3
    • 17
  • s

    spierce7

    03/18/2020, 5:06 PM
    My company is in the process of trying to migrate from the individual platform plugins to the
    multiplatform
    plugin. We are migrating one module at a time. We’re seeing a crash when running tests:
    Unable to find a matching variant of com.rallyhealth.store:store:0.1.9:
              - Variant 'android-debugApiElements' capability com.rallyhealth.store:store:0.1.9:
                  - Incompatible attribute:
                      - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'androidJvm'.
    com.rallyhealth.store is a private lib. Does anyone know anything about this?
    l
    • 2
    • 1
  • s

    spierce7

    03/19/2020, 2:17 AM
    Are `Flow`s safe to pass between threads in Kotlin/native?
    e
    • 2
    • 1
  • z

    zalewski.se

    03/19/2020, 7:12 AM
    I was trying to update kotlin version to
    1.3.70
    but I’m getting an error:
    > Task :network:linkDebugFrameworkIosX64 FAILED
    e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    My other dependencies versions are:
    coroutinesVersion=1.3.5
    ktorVersion=1.3.2
    serializationVersion=0.20.0
    If I set the kotlin version to
    1.3.61
    and dependencies to:
    coroutinesVersion=1.1.1
    ktorVersion=1.2.4
    serializationVersion=0.11.1
    It’s building fine 🤔… Has anyone had simial problem? I was trying on many different gradle wrapper versions, right now I’m on the latest one
    6.3-rc-3
    e
    a
    • 3
    • 10
  • i

    ilya.matveev

    03/19/2020, 9:21 AM
    Regarding the problem above. The following snippet helps to avoid the library names clash. It uses group+name of a Gradle module as a library name, making this name more or less unique. cc @zalewski.se @alex009 UPD: We also recommend library authors who use 1.3.70/1.3.71 to rebuild and republish their libraries with this snippet. It will protect users of your library from potential name clashes. Kotlin DSL:
    Untitled
    👍 4
    👏 1
    ➕ 1
    m
    z
    r
    • 4
    • 8
  • d

    dazza5000

    03/19/2020, 2:24 PM
    How do I add a libs directory to a kotlin mp android declaration?
    k
    • 2
    • 1
  • g

    Gunslingor

    03/19/2020, 2:40 PM
    I could really use some help, I don't understand why main runtime dependency is returning a config while the test runtime dependancy is, correctly, producing a file collection..... oddly enough this task doesnt run unless the classpath is set to the test one which makes no sense!
    k
    • 2
    • 13
  • c

    Christian Sousa

    03/20/2020, 11:01 AM
    anyone has a lib that makes sha256 on multiplatform? thank you 🙂
    j
    • 2
    • 1
  • c

    Christian Sousa

    03/20/2020, 11:31 AM
    I’m getting this error:
    Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen com.jetbrains.handson.mpp.mobile.services.deviceStorage.DeviceStorage@2164548
    Even though my DeviceStorage has
    import kotlin.native.concurrent.ThreadLocal
    
    @ThreadLocal
    object DeviceStorage {
    ...
    }
    Anyone knows how to get this to work?
    k
    • 2
    • 1
  • c

    CLOVIS

    03/20/2020, 1:29 PM
    I have something like:
    // commonMain/File 1 Everything is top level
    private val a = ...
    internal fun b() { do something with a }
    public fun c() { call b }
    // commonTest/File 2 In a class
    @Test
    fun testB() { b() }
    @Test
    fun testC() { c() }
    In Kotlin/JVM, both test run fine. In Kotlin/JS,
    testC
    runs fine, but
    testB
    breaks with
    ReferenceError: a is not defined
    . To me it looks like that means that Kotlin/JS tests are allowed to call internal functions, but if they do, then those functions cannot find private vals they should be able to find otherwise? Either I misunderstood something, or there might be some buggy behavior involved.
    b
    • 2
    • 1
  • s

    Sebastian

    03/20/2020, 1:55 PM
    Hey there kotlin community! I’m working on a iOS/Android kotlin multiplatform small project where I want to display an image fetched from the network. I’m new to multiplatform but I know Android and Kotlin well enough. I have one concrete question: With the current available libraries, is most of the code for such a use case going to be shared or will I need to build the image views and the fetching in kotlin and in swift, only sharing the HTTP fetch code?
    m
    • 2
    • 9
  • g

    Gunslingor

    03/20/2020, 5:23 PM
    What is wrong with my webpack multiplatform project code, I don't think the dependcies like three.js are getting packed.
    js("frontend") {
        browser {
            tasks {
                register<Exec>("webpack") {
                    dependsOn("yarn", "npmInstall")
                    //outputs.dir("$buildDir\\yyy\\")
    
                    commandLine("$buildDir\\js\\node_modules\\.bin\\webpack", "$buildDir\\js\\packages_imported\\kotlin\\1.3.70\\kotlin.js", "$buildDir\\js\\packages_imported\\three.js\\71.0.0-r\\three.js")
                    //, "$buildDir\\js\\packages_imported\\kotlin\\1.3.70\\kotlin.js", "$buildDir\\js\\packages_imported\\three.js\\71.0.0-r\\three.js"
                }
            }
        }
    }
    r
    • 2
    • 24
  • b

    bod

    03/21/2020, 9:08 AM
    Hello, World! So I've tried to update my project's dependencies to the latest (including Kotlin 1.3.70), and now I'm getting this:
    w: skipping /Users/bod/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-io-iosx64/0.1.16/dafe6011ea63ea7200a43bcff435a46204a1b1b8/kotlinx-io.klib. The abi versions don't match. Expected '[22]', found '17'
    e: Could not find "/Users/bod/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-io-iosx64/0.1.16/dafe6011ea63ea7200a43bcff435a46204a1b1b8/kotlinx-io.klib" in [/Users/bod/gitrepo/klibqonto, /Users/bod/.konan/klib, /Users/bod/.konan/kotlin-native-macos-1.3.70/klib/common, /Users/bod/.konan/kotlin-native-macos-1.3.70/klib/platform/ios_x64].
    Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
    It looks like it's a
    kotlinx-io
    issue, but what exactly, and what can I do (if anything)? Thanks a lot!
    l
    d
    +2
    • 5
    • 13
  • c

    coletz

    03/21/2020, 3:19 PM
    Hi guys, how do you handle concurrent access to a map in a multiplatform project (jvm/native)? On the jvm side I would use a ConcurrentHashMap or something similar, but afaik there's nothing like that on k/n. Basically I am using this map for keeping reference to some lambda in order to call them when another variable is changed (basically a super simple listener). But I'm having obvious problems when removing a key while the underlying variable changes (which leads to a ConcurrentModificationException since I'm looping on the map) (ps: the problem is not removing a key INSIDE the loop, it's when another thread calls the remove method)
    l
    r
    k
    • 4
    • 19
  • f

    fcosta

    03/22/2020, 1:45 AM
    I'm trying to use some iOS APIs in my recent multiplatform project (without CocoaPods) and IntelliJ can't find
    Foundation
    ... Any idea of what i'm doing wrong?
    package sample
    
    import platform.Foundation.NSString
    
    actual class Sample {
        actual fun checkMe() = 7
    }
    
    actual object Platform {
        actual val name: String = "iOS"
    }
    
    actual fun formatString(source: String, vararg args: Any): String {
        return ""
    //    return NSString.initWithFormat
    }
    r
    c
    p
    • 4
    • 14
  • g

    Gunslingor

    03/22/2020, 3:11 AM
    Does kotlinX html transpile to html or javascript that later generates html, seems to be the later to me... does anyone know if thats better or worse, I would imagine worse. Not sure what kotlinx html for jvm is compiling too... a string buried in a jar maybe? I mean which is better, generating html templates with kolinx jvm, js or common (would common work)? I suspect its best to generate the templates at the bad side and then send pure html that gets modified... but If my JS is in my frontend and my templates are in my backend how could I ever organize by module?
    s
    • 2
    • 94
  • b

    Big Chungus

    03/22/2020, 5:27 PM
    Any ideas how i can declare
    expect
    of the folowing JS class in common module so I could
    typealias
    it in JS module?
    class ExternalAPI {
      val important: dynamic
    }
    k
    • 2
    • 5
  • g

    Gunslingor

    03/23/2020, 4:59 PM
    Why does this work:
    document.body?.appendChild(renderer.domElement)
    While this doesn't?
    val target = document.getElementById("right_pane")?
    target?.appendChild(renderer.domElement)
    document.body? is an Element and document.body? is an HTML element.... not sure why there are two but there has to be a converter or something... or someway to make this work. Elements seems to allow appending a string as HTML via innerHTML while HTMLElements seem to do something with Nodes... don't really get this, feels like object interfaces aren't formalized.
    a
    • 2
    • 4
  • g

    Gunslingor

    03/24/2020, 6:17 AM
    I can't seem to get my frontendBrowserTests to work, the frontendTests Work but it keeps complaining about node setup failed. Any thoughts?
    js("frontend") {
        compilations {
            create(environment) {
                browser {
                    tasks {
                        val backendJar by getting {
                            dependsOn("frontendBrowserWebpack")
                        }
                        webpackTask {
                            setProperty("mode", environment)
                            //sourceMaps = false // Set 'true' if need debug
                            //report = true // Enable execute tests src/jsTest
                        }
                        testTask {
                            dependsOn("backendJar", "npmInstall")
                            useKarma {
                                //useIe()
                                //useSafari()
                                //useFirefox()
                                //useChrome()
                                //useChromeCanary()
                                useChromeHeadless()
                                //usePhantomJS()
                                //useOpera()
    
                            }
                        }
                    }
                }
            }
        }
    }
    i
    • 2
    • 55
  • n

    Nikolay Kasyanov

    03/24/2020, 10:17 AM
    https://youtrack.jetbrains.com/issue/KT-37730 is anyone else affected by this? Workarounds would be appreciated .
    r
    • 2
    • 3
  • s

    Slackbot

    03/24/2020, 12:04 PM
    This message was deleted.
    a
    • 2
    • 1
  • a

    araqnid

    03/24/2020, 2:32 PM
    I’ve just tried making a multiplatform library, and I can actually use it as a dependency in downstream apps, but the only thing missing is the sources when I click through into one of the library’s classes (both js and jvm downstream consumers) Searching here for mentions I found this: https://kotlinlang.slack.com/archives/C3PQML5NU/p1573209686439300 I had a look in my local maven repo, and indeed, the sourcesElements that Gradle usually puts in for a maven publication are missing from the module files published here. The library doesn’t specify any publishing configuration at all, the multiplatform plugin is synthesising the publications entirely- which is cool, as far as it goes, just not quite all the way there yet… This is with Gradle 6.2, and I get the same results with K 1.3.71 and 1.4-M1. Also, the sources in the sources jar that is written to the repo include the “commonMain/” prefix, is that expected?
    :youtrack: 1
    l
    • 2
    • 17
  • g

    Gunslingor

    03/24/2020, 5:18 PM
    The thing I hate most about gradle in multi project: When I have a problem it's impossible to address it directly and effectively. I find myself having to change and experiment with 200 things using trial and error until I get the right combination... I find this is constant, I hit a wall like this every couple days and it takes a few days to get around it. Something tells me the imperative nature of previous build systems would not suffer from this, I personal suspect the issue is documentation or maybe I am missing something obvious but it seems like gradle build file is really more of a functional config than a program, but not all possible fields and allowed values and combinations of this config are clearly setup or defined (a lot like CSS if you ask me, lol). Thoughts?
    k
    i
    • 3
    • 17
  • c

    Chills

    03/24/2020, 5:23 PM
    we have our current product in Xamarin(F#) we would love to move to kotlin native do you have any support free/paid? we have over 10K users atm
    c
    g
    a
    • 4
    • 3
  • o

    Orhan Tozan

    03/25/2020, 4:23 AM
    In a Multiplatform multi-module project, should a kotlin module that exposes Flow as its public api, specify its coroutines dependency as
    api
    instead of
    implementation
    ? What about target dependencies (e.g. commonMain:
    api(coroutines-core-common)
    and jvmMain:
    api(coroutines-core)
    )
    l
    • 2
    • 3
  • m

    Marc Dietrichstein

    03/25/2020, 8:58 AM
    Hi everyone, I'm working on a multiplatform (iOS/Android) library for Firebase Analytics. In principle everything works fine, but the resulting iOS framework is quite large (30MB). It looks like kotlin generates an umbrella framework which includes all the other framework dependencies I have defined via
    linkerOpts
    and
    compilerOpts
    in my
    cinterop.def
    file (FirebaseCore, nanobp etc.) This also leads to "duplicate symbol" issues when the framework is embedded in our app, since we are using cocoapods which pulls in transitive dependencies that are already embedded in our analytics library. Is there any cinterop flag or gradle option to tell kotlin not to embed subframeworks?
    i
    • 2
    • 5
  • k

    kenkyee

    03/25/2020, 11:00 AM
    From the 1.4M1 release notes: "to make Swift code aware of expected exceptions, Kotlin functions should be marked with a @Throws annotation specifying a list of potential exception classes." Does this include runtime exceptions? E.g. IllegalStateException?
    l
    n
    • 3
    • 4
  • s

    Sylvain Patenaude

    03/25/2020, 4:19 PM
    What's the best way to generate an .aar file from a multiplatform build.gradle file? My iOS targets generate .framework outputs, but I would now like to wrap my android target jar file in an .aar file. Thanks in advance.
    k
    • 2
    • 33
  • d

    Dominaezzz

    03/25/2020, 6:23 PM
    How to convert a unicode codepoint (
    Int
    ) to a
    String
    ?
    r
    • 2
    • 2
  • k

    Kris Wong

    03/25/2020, 8:35 PM
    does 1.3.71 create an
    iosTest
    task?
    r
    • 2
    • 7
Powered by Linen
Title
k

Kris Wong

03/25/2020, 8:35 PM
does 1.3.71 create an
iosTest
task?
i mean, i technically know the answer is yes, just surprised by, and curious about that 🙂
the interesting bit is that I am doing some manual file coyping/deletion in one of my projects as a part of this task
r

russhwolf

03/25/2020, 8:38 PM
You could probably keep your custom task if you need it, as long as you give it a different name
The built-ins are nice to have though. And it now integrates into the IDE
k

Kris Wong

03/25/2020, 8:45 PM
that's definitely nice
now if only it supported resource files
tasks.named("iosTest") {
    doFirst {
        copyTestResourceFiles()
    }
    doLast {
        cleanupTestResourceFiles()
    }
}
View count: 3