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

    yshrsmz

    12/16/2019, 10:43 AM
    Does anyone successfully configured KMP(ios & android) with 1.3.61? When I set
    kotlin.mpp.enableGranularSourceSetsMetadata=true
    , Some expect/actual definition does not resolve its type correctly in commonMain and android app module. When I set
    kotlin.mpp.enableGranularSourceSetsMetadata=false
    , androidMain does not resolve android classes My app was working fine when I used 1.3.50.
    r
    3 replies · 2 participants
  • d

    dambakk

    12/16/2019, 1:51 PM
    Hi, everyone! I want to discuss how the multiplatform project relates to the native (in my case; android and ios) projects. As I see it there are three approaches: • Keep everything in the same repo. Pros: everything in the same place. Cons: Messy git history or use of git submodules. • Keep the android and common project in the same project. Pros: Easy android integration and debugging. Easy to pack and inject an ios framework. Cons: Debugging from ios? Common project “owned” by the android project (higher threshold for ios devs to contribute to the project) • Three separate projects. Pros: Clean separation, non-android driven. Cons: Debugging?  Tl;dr: What is the recommended way of structuring such a multiplatform project? The code labs and examples I’ve seen choose different approaches. And while we’re at it, what is the best way for ios devs to debug the common code?
    🔝 2
    👍🏻 1
    r
    k
    +3
    20 replies · 6 participants
  • g

    galex

    12/16/2019, 2:19 PM
    Hello, did someone manage to publish the two library variants to Artifactory? I am talking about the following:
    android {
        publishLibraryVariants("release", "debug")
    }
    Any
    build.gradle
    example would be more than welcomed 🙂
    d
    r
    4 replies · 3 participants
  • h

    horothesun

    12/16/2019, 3:58 PM
    Hi everybody! 👋 😊 It looks like there're no SocketIO client KMP libraries atm, so I was thinking about starting from the current native Swift version, somehow wrapping it into a Kotlin Native library. This feels like the exact opposite 'flow' compared to the "implement it in Kotlin Native" logic. Does this approach even make sense? Are there alternative approaches to reimplementing a SocketIO client library in Kotlin Native? Thanks 🙏
    m
    m
    2 replies · 3 participants
  • e

    etolstoy

    12/16/2019, 4:47 PM
    Hi everyone! We’re very concerned about how easy it is for you to use Kotlin. One of the tricky parts is the memory model in Kotlin/Native. We’ve prepared a research to understand how well people understand various aspects of memory management. Walk through 10 code snippets and tell us, if you think that the output is correct and if you understand why it behaves so. The research is designed both for experienced developers and newcomers. Feel free to use our documentation, and thanks a lot for your participation! ❤️ https://surveys.jetbrains.com/s3/kotlin-native-memory-model-research
    k
    i
    +4
    12 replies · 7 participants
  • k

    Konstantin Petrukhnov

    12/17/2019, 8:07 AM
    @etolstoy @hhariri Some samples/snippets, that allow to add features implemented with MPP/KN to existing ios/android projects could help with adoptability of Kotlin to existing projects. E.g. there is 4 projects: kalina-ios, kalina-android, oka-ios, oka-android. None of them use Kotlin. They have HTTP/DB/whatever functionality inside them. Now we want to add one new feature to all of them. Implementing with Kotlin make sense, as we could implement 70% of new functionality in common code only, and whole module, may be implemented by 90% with kotlin. Lets assume that new functionality require to modify fields of 1.000.000 objects and show first 1000 of them in UI. New people coming to Kotlin need to understand: * How to structure, build and import library into existing projects? Existing Kotlin documentation don't answer that. Examples in internet are misleading. * Is it coroutines/workers/gdc/syncronize/etc that could be applied to run update operation in background (that may take 10+ seconds)? * Where should be code that handle multitreading: commonMain, kotlin ios/android, swift/java? * Where to put tests: common, ios/android? * How to make multiple kotlin libraries to play together? * What are the performance impacts of doing things in Kotlin? E.g. if there is need to update fields for 1.000.000, does all of them need to be copied (immutability)? Code snippets, diagrams, project samples, that address these questions will help people to learn expected way to work with Kotlin.
    👍 3
    k
    k
    +1
    4 replies · 4 participants
  • j

    jdiaz

    12/17/2019, 8:19 PM
    Is it possible to enable the endorsed libs in the commonMain sourceset?
    e
    2 replies · 2 participants
  • s

    Sam

    12/18/2019, 2:34 AM
    I'm trying to create a multiplatform library. I created one from IntelliJ project setup, replaced jvm target with android target with other android specific changes to build.gradle. Setup compiles fine and generates artifacts but it is just a jar. Am i missing something for it to generate an aar?
    b
    3 replies · 2 participants
  • j

    james

    12/18/2019, 4:24 AM
    How do you enable the compiler flag for experimental generics '-Xobjc-generics' if using the cocoapods plugin?
    k
    2 replies · 2 participants
  • k

    Kurt Renzo Acosta

    12/18/2019, 6:19 AM
    Does anyone know why this is happening? BaseFragment is defined on Android by
    BaseFragment<T: ViewModel>
    LoginViewModel
    is in my common code through this
    class LoginViewModel : BaseViewModel()
    And
    BaseViewModel
    just expects
    expect open class BaseViewModel()
    // Android
    actual open class BaseViewModel actual constructor(): ViewModel()
    // iOS
    actual open class BaseViewModel actual constructor()
    My code compiles normally, so I'm thinking this is just an IDE bug but I'm not sure. Maybe I did something wrong...
    t
    2 replies · 2 participants
  • k

    Konstantin Petrukhnov

    12/18/2019, 11:42 AM
    Is there any library for TCP/UDP connections? Need only for ios.
    j
    3 replies · 2 participants
  • s

    Sam

    12/18/2019, 5:05 PM
    Is there a recommended way to create androidMain and androidTest modules?
    k
    28 replies · 2 participants
  • k

    kpgalligan

    12/18/2019, 11:05 PM
    Updated post if you want to poke around https://twitter.com/kpgalligan/status/1207431332206456832?s=21
    👍 6
    e
    2 replies · 2 participants
  • i

    ian.shaun.thomas

    12/19/2019, 2:38 PM
    With a multimodule project, using a multiplatform project as a shared module and a module for web, is it not possible to use the
    js
    plugin in the web module? All I get is this:
    Cannot add extension with name 'kotlinNodeJs', as there is an extension already registered with that name.
    Library module is using
    kotlin("multiplatform")
    plugin and JS web module is using
    kotlin("js")
    . The error is triggered when trying to enable browser or nodejs as a target in the js module when browser or nodejs are enabled in the common mpp module. ie:
    js {
            browser {}
            nodejs {}
        }
    I can't find examples of anyone using these together so I guess it's not possible right now?
    r
    5 replies · 2 participants
  • b

    bod

    12/19/2019, 4:53 PM
    is it still not possible to use ktor-client with 1.3.61?
    k
    b
    +1
    10 replies · 4 participants
  • k

    Kris Wong

    12/19/2019, 6:53 PM
    anyone know how to do this in kotlin DSL?
    maven {
        url = <http://java.net|java.net>.URI("<https://dl.bintray.com/suparnatural/kotlin-multiplatform>")
    }
    c
    e
    4 replies · 3 participants
  • r

    rattleshirt

    12/20/2019, 9:36 AM
    In the new native-mt model what would be the equivalent of Dispatchers.IO for iOS in a AppCoroutineDispatchers class with main = Main, computation = Default and io? Would that be
    newSingleThreadContext("io")
    ?
    d
    k
    4 replies · 3 participants
  • b

    bod

    12/20/2019, 3:07 PM
    Well, I've made my
    Page<T>
    a class instead of an interface, and it still doesn't work. Ideas?
    k
    7 replies · 2 participants
  • c

    Cristián Arenas

    12/20/2019, 3:44 PM
    We have an Android library published to Maven local, we want to debug the library on the Android project that installs it. Neither
    Download Sources
    nor
    Choose Sources…
    is working for us. How can we achieve this?
    6 replies · 1 participant
  • k

    Kris Wong

    12/20/2019, 5:07 PM
    has anyone used channels? this example shows constructing a
    Channel
    https://github.com/kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt, but
    Channel
    is an interface
    d
    k
    22 replies · 3 participants
  • c

    Casey Brooks

    12/20/2019, 6:57 PM
    Is it possible to run a suspending test in Kotlin/Native for iOS? I’m trying to test a Ktor client. I get immutability exceptions when doing
    runBlocking
    , so I tried to set up a polling solution with
    .launch { }
    and
    usleep()
    , but it doesn’t seem like the launched block ever executes.
    2 replies · 1 participant
  • e

    egorand

    12/20/2019, 7:19 PM
    If the native artifact of a multiplatform library is published as
    klib
    , is there a way for the consumer to transform it into a
    framework
    ? Or does it have to be published as a
    framework
    ?
    s
    2 replies · 2 participants
  • k

    Kris Wong

    12/20/2019, 7:58 PM
    very interesting - the IDEA debugger hangs when attempting to debug my common tests
    k
    4 replies · 2 participants
  • k

    kpgalligan

    12/20/2019, 10:06 PM
    Assume you mean for iOS output? You kind of need a wrapper with a callback
    k
    2 replies · 2 participants
  • d

    Dmitri Sh

    12/21/2019, 3:12 AM
    Good day today. The KMP project we have been working on for the annual CodeWeek event is a finalist! 250 teams competing, we are one of the top 25 going into the finals in January. WatchOS KTOR client made it just in the nick of time! Still needs polishing and a good amount of refactoring, but I think the main point proven - we share logic and networking across multiple targets (and planning to add more) https://github.com/dmitrish/kinsight-multiplatform
    k
    2 replies · 2 participants
  • b

    bod

    12/22/2019, 12:48 PM
    Anybody has experience with
    runBlocking
    working on iOS? 😛 (spoiler alert: in my case, it just freezes)
    d
    k
    4 replies · 3 participants
  • k

    kpgalligan

    12/22/2019, 6:00 PM
    Anybody have experience using non-oracle JDK’s? Thinking something like Amazon Corretto or similar. You can still get the oracle jdk, but you need to make an oracle account, and the new license notices is kind of off putting. I’m thinking for iOS devs (and others) unfamiliar with the Java world, the whole Oracle install process would be best avoided.
    a
    d
    +4
    21 replies · 7 participants
  • j

    Joey

    12/23/2019, 5:37 AM
    Hi guys, what is the most efficient way of importing existing kotlin multiplatform module to an old android project?
    h
    k
    4 replies · 3 participants
  • k

    Kurt Renzo Acosta

    12/23/2019, 10:40 AM
    Hello. How do you configure the framework produced by cocoapods? I'm trying to do a:
    iOSTarget("ios") {
        compilations {
            val main by getting {
                kotlinOptions.freeCompilerArgs = listOf("-Xobjc-generics")
            }
        }
    
        binaries {
            framework {
                export(project(":shared-module-1"))
                export(project(":shared-module-2"))
            }
        }
    }
    But I'm getting a
    Cannot create binary debugFramework: binary with such a name already exists
    If I name it
    framework("MyFramework")
    , it works but it doesn't build with cocoapods.
    k
    2 replies · 2 participants
  • n

    nrobi

    12/23/2019, 11:57 AM
    Did anyone struggle with
    kotlinx-serialization
    ? I’m using
    0.14.0
    , and I’m gettin pretty randomly
    java.lang.NoClassDefFoundError:
    , some time it works, some time it doesn’t 🤷
    m
    3 replies · 2 participants
Powered by Linen
Title
n

nrobi

12/23/2019, 11:57 AM
Did anyone struggle with
kotlinx-serialization
? I’m using
0.14.0
, and I’m gettin pretty randomly
java.lang.NoClassDefFoundError:
, some time it works, some time it doesn’t 🤷
Also what’s the best way to handle
List
parsing in a generic way?
m

molikuner

12/23/2019, 2:33 PM
There is a
KSerializer<T>.list
. Thats probably the most generic think you can get. Maybe via reflection a little bit more, but I wouldn’t recommend it. What do you need exactly?
n

nrobi

12/24/2019, 11:48 AM
Yes, I use that on the client side. What I want is to be able to parse a json, which has a
field: List<T>
with
call.receive<MyModel>
View count: 1