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

    Deactivated User

    10/05/2017, 5:40 PM
    I'd suggest adding the possibility of creating pure common libraries. Without having to manually implement them. Example: https://github.com/korlibs/korge/tree/ad5089fcf6fbc3849c8c8592752ba98ac735b804 Here I have a lot of sublibraries/extensions that I have to implement per target. Which is a bit crazy. Because all of them uses other common libraries and no platform-specific code. I think that you can just upload common versions and "instantiate" platform specific-artifacts locally. Either at build/ or in an external cache folder. Or even allowing to create a single jar with JVM code + other code embedded. Since the initial implementation should be simple I understand that it is not a priority right now, but I'd vote for it for a later release 🙂
    ➕ 2
    e
    r
    • 3
    • 4
  • d

    Deactivated User

    10/05/2017, 5:58 PM
    I still have to check how kotlinx.serialization works and how to create a plugin to do the same for my asynchronous injector and avoid to manually or automatically having to generate a file like this: https://github.com/korlibs/korge-samples/blob/master/korge-tic-tac-toe/src/com.soywiz.korge.tictactoe/InjectExt.kt#L8
    g
    • 2
    • 1
  • g

    gaetan

    10/09/2017, 10:32 AM
    One question on visibility: I have a common module with a function indicated as
    internal
    . I have a jvm module that implements this module. My test code inside the jvm module does not see the internal function. Is this normal?
    o
    i
    • 3
    • 4
  • s

    snrostov

    10/10/2017, 8:51 PM
    Trying to create multiplafrom project by: File > New > Project > Kotlin > Kotlin (Multiplatform - Experimental). Error after gradle import complete: https://pastebin.com/fZ2euzpS Same with https://github.com/jstuyts/kotlin-multiplatform-recipes/tree/syntax-1.2 (branch syntax-1.2).
    • 1
    • 2
  • s

    snrostov

    10/11/2017, 3:56 PM
    Which version of IDEA, IDEA plugin and Gradle plugin is preferred for working with multiplatform project? In 1.2-EAP references from application module to common module not resolved in idea (red)
    g
    l
    i
    • 4
    • 8
  • d

    Deactivated User

    10/14/2017, 11:51 PM
    Is there a way for using
    org.intellij.lang.annotations.Language
    annotation in common code?
    i
    • 2
    • 2
  • j

    jossiwolf

    10/20/2017, 4:22 PM
    Hey! I'm trying to use Reagent (github.com/jakewharton/reagent), but I get a "Unresolved Reference: Observable" error when compiling This is my code:
    import reagent.Observable
    
    expect interface ExampleAPI {
    
        fun getUsers(): Observable<UserModel>
    
    }
    This is the error from Gradle:
    Unresolved reference: Observable
    Anything I'm not seeing there? This code is in the common module of my project
    o
    • 2
    • 2
  • d

    Deactivated User

    10/29/2017, 3:15 PM
    Is this reported? https://travis-ci.org/soywiz/kpspemu/builds/294470924#L967
    e: java.lang.IllegalStateException: Cannot get FQ name of local class: class <no name provided>
    	at org.jetbrains.kotlin.serialization.StringTableImpl.getFqNameIndexOfLocalAnonymousClass(StringTableImpl.kt:79)
            ...
    ➕ 1
    i
    • 2
    • 3
  • d

    Deactivated User

    10/31/2017, 1:21 PM
    I'm facing an intermittent
    Actual ... has no corresponding expected declaration
    since first version, when compiling with gradle. I have recorded a video reproducing the problem. It seems that it happens when modifying a file containing an actual. When having two modules with expectedBy using platform-jvm. I have android + jvm doing this.

    https://youtu.be/DsqGGRimTnY▾

    i
    • 2
    • 2
  • i

    ilya.gorbunov

    11/05/2017, 3:42 AM
    @Deactivated User Could you debug it a little? I'll DM you the hints.
    👍 1
    d
    • 2
    • 1
  • i

    ilya.gorbunov

    11/06/2017, 10:54 PM
    @snrostov This case isn't supported, feel free to open a feature request for that, but please describe your use case there.
    s
    • 2
    • 4
  • g

    gregopet

    11/08/2017, 8:39 AM
    I have a Kotlin common module that is being consumed by JVM and JS code and it works using Gradle; IntelliJ keeps complaining about classes like
    Int
    missing in the common module, though, even though the module's target platform is marked as
    Common (experimental)
    and the language version is at 1.2 - any hints on what I could try?
    i
    • 2
    • 9
  • i

    ilya.gorbunov

    11/08/2017, 3:00 PM
    @voddan No there's no such plans: first, platform modules would not be a convenient replacement for this feature, second, splitting the standard library for each JVM version would fragment the libraries that built on top of it.
    👍 1
    v
    • 2
    • 4
  • j

    jstuyts-squins

    11/10/2017, 7:50 AM
    Tests in a common module are run as part of the tests of the actual platform modules
    s
    • 2
    • 2
  • i

    ilya.gorbunov

    11/10/2017, 7:59 PM
    @spierce7 Yes, to run tests in JS you need to add some setup to the js project, see this post for details and samples: https://discuss.kotlinlang.org/t/unit-testing-in-kotlin-js/3943
    s
    • 2
    • 2
  • c

    czuckie

    11/22/2017, 8:05 AM
    can someone help us out with my broken understanding: If I have multiplatform project with a jvm target, js target and common project- how do I handle incompatibilities with common datatypes (e.g. kotlin.String vs java.lang.String) and the apparent lack of
    Int
    ?
    g
    • 2
    • 2
  • c

    czuckie

    11/22/2017, 8:19 AM
    so … as is the rule when asking for help online- moments later I stumbled to the solution. I had to specify the common project as expectedBy my jvm target- which is like the first step of any of this, but my jvm target isn’t really providing any implementations, just sharing common classes currently
    s
    • 2
    • 1
  • p

    pdvrieze

    11/22/2017, 10:59 AM
    I have a case that I'm not sure is supported. Basically I have a library that provides XML related functions for Android, JVM and JS with a common api. All three targets have different underlying libraries that I will use. At the same time Android and JVM do share some commonalities that are not present for JS. As such I would like to have a common module ("common-android-jvm") that provides the implementation for some expects as that are declared in the fully common module. It doesn't seem possible to do that. Of course the android and jvm modules could duplicate the code (but I'd like to avoid that). Anyone know whether this is an oversight of me, or is this a "missing" feature
    👍 1
    g
    • 2
    • 3
  • m

    mersan

    11/22/2017, 8:34 PM
    Hi, can I find a sample of native kotlin targeting Android and iOS on the same code?
    k
    s
    • 3
    • 5
  • s

    spand

    11/23/2017, 7:52 AM
    I am still new to this multiplatform but why is this a type error:
    Required: (kotlin.text.Appendable /* = java.lang.Appendable */) -> Unit
    Found: (kotlin.text.Appendable) -> Unit
    g
    • 2
    • 6
  • s

    spand

    11/23/2017, 9:41 AM
    If anyone would like to take a look: https://github.com/spand/kotlin-multi-platform It builds in gradle but IDEA fails the build. Also hovering on
    app
    variable read in foo/kotlin/.../Foo.kt the previous mentioned type error is shown
    i
    • 2
    • 3
  • n

    natpryce

    11/30/2017, 7:18 AM
    But is there an
    expect
    definition in the stdlib for common? I’m using 1.2.0 and IntelliJ is showing compilation errors for uses of Comparator in common modules
    i
    • 2
    • 1
  • s

    spand

    11/30/2017, 7:57 AM
    IDEA still has some issues with multiplatform code
    n
    • 2
    • 1
  • m

    marcinmoskala

    12/03/2017, 10:57 AM
    Is it possible to have Android module which is also platform module? To omit common-jvm?
    r
    • 2
    • 1
  • a

    avolkmann

    12/05/2017, 7:58 PM
    How to resolve the "Cannot add extension with name 'kotlin', as there is an extension already registered with that name." error ?
    i
    • 2
    • 3
  • s

    seanf

    12/06/2017, 2:54 PM
    Has anyone found a good option for multiplatform localisation/L10n? Preferably a typesafe option. I'm trying to migrate a GWT project which uses type-safe messages (http://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/Messages.html). Basically the GWT compiler generates the English .properties file from a messages interface - method names become property keys, annotation values provide the English strings - and also generates runtime classes to provide the translations (taken from the translated .properties files). I don't need compile-time class generation - Java/ES6 Proxy objects at runtime would be fine, but I would need a way to generate the English .properties file in the
    common
    (not
    jvm
    or
    js
    ) module - which means I can't just use reflection to examine .class files from a Gradle plugin. I'm starting to think I need an annotation processor - but will that work in a
    common
    module? (Update: apparently it won't.)
    b
    p
    • 3
    • 18
  • a

    agrosner

    12/06/2017, 4:01 PM
    ive only seen examples for multiplatform where Android is used as the app. is there an example of a multiplatform project that has android as a library? ive tried applying
    com.android.library
    with
    kotlin-platform-jvm
    which doesnt work. also there isn't a
    kotlin-platform-android
    . Is there something I am doing wrong here?
    i
    • 2
    • 2
  • m

    Mark

    12/07/2017, 3:41 AM
    Hey @elizarov or any other helpful friends, I'm currently messing around with a multi-platform project and I am trying to get coroutines up and running. I have
    kotlinx-corountines-core
    imported through my common module and I have been successfully using it transitively in the JVM project (a little TornadoFx visualizer) to do a bit of processing off of the main thread. However, I am now trying to speed up some of the common logic and I've just started getting an unresolved reference to
    kotlinx
    ,
    runBlocking
    and
    launch
    when compiling the common module. Is there something special I need to do in the Gradle imports to ensure that I am getting an implementation of coroutines that is compatible with Kotlin common? Some other trick that I am missing?
    g
    • 2
    • 10
  • a

    alex.hart

    12/07/2017, 4:55 PM
    Hello, I was wondering if you are considering adding some warnings around when a developer includes a dependency that targets the JVM? I am currently developing a multiplatform project and chose to use Kategory to build out my core architecture, but it appears it’s a JVM only project right now. While this is fine because I am going to build out Android first, I was wondering what the future may hold for warnings and other build tooling around the detection of such things.
    m
    e
    s
    • 4
    • 9
  • m

    marcinmoskala

    12/10/2017, 5:38 PM
    Hey, guys. I will officially publish it tomorrow (in Monday) at around 9 GTM but it would be really nice to have some feedback before. It is really important article for me and I hope it will be also for multiplatform Kotlin development. I am still doing corrections but every feedback is appreciated. Even typos or misspells. (post will be published in medium, but I've changed link to docs so everybody can add comment) Docs where you can comment and suggest changes: https://docs.google.com/document/d/1PnLpA9RLvVy_n2vcdRZ0q1AT4dC_0d3IAZ_ZwyjuRac/edit?usp=sharing How article looks like: https://blog.kotlin-academy.com/architecture-for-multiplatform-development-in-kotlin-cc770f4abdfd
    👍🏽 5
    j
    i
    g
    • 4
    • 19
Powered by Linen
Title
m

marcinmoskala

12/10/2017, 5:38 PM
Hey, guys. I will officially publish it tomorrow (in Monday) at around 9 GTM but it would be really nice to have some feedback before. It is really important article for me and I hope it will be also for multiplatform Kotlin development. I am still doing corrections but every feedback is appreciated. Even typos or misspells. (post will be published in medium, but I've changed link to docs so everybody can add comment) Docs where you can comment and suggest changes: https://docs.google.com/document/d/1PnLpA9RLvVy_n2vcdRZ0q1AT4dC_0d3IAZ_ZwyjuRac/edit?usp=sharing How article looks like: https://blog.kotlin-academy.com/architecture-for-multiplatform-development-in-kotlin-cc770f4abdfd
👍🏽 5
j

JacobPed

12/10/2017, 6:11 PM
This is really great work, thank you very much for your effort and sharing it. I've been looking forward to this article. 😄 I really like how you explained the module splits and how they relate. One thing I think would be nice for a future article is an explanation of your gradle scripts and how they relate. I tried to get an understanding of how your compilation works with all the modules but it looked so incredibly complex. Especially the JavaScript modules. I clearly have a lot to learn, but it's a topic that's barely any information about in any articles I've read. 🙂
Oh, it would probably be a good idea to include a link to your Github repository for the project.
m

marcinmoskala

12/10/2017, 6:39 PM
Thanks a lot 🙂 I am planning to make separate article about gradle in multiplatform project but before that I will have to clean-up and fix all my scripts first xP It was not such a high priority so I was satisfied with working state but there is still a lot to be done in this subject. I also have to go deeper into WebPack. BDW Udacity have great free course for Gradle 🙂 https://www.udacity.com/course/gradle-for-android-and-java--ud867
I have added the link. Thanks for the suggestion
i

ilya.gorbunov

12/11/2017, 12:54 AM
"is interop with" doesn't sound good to me. Maybe it'd better "has interop with" or "is interoperable with"?
💯 1
👍 1
What is the difference between plain modules and common modules?
m

marcinmoskala

12/11/2017, 3:39 AM
@ilya.gorbunov Common modules can have expected declarations of platform dependent types and functions https://kotlinlang.org/docs/reference/multiplatform.html
i

ilya.gorbunov

12/11/2017, 3:39 AM
And plain modules? What are they then?
m

marcinmoskala

12/11/2017, 3:41 AM
You can make just plain kotlin module/library. It is defined differently and cannot have expected declarations but we don't need to make platform modules to it
i

ilya.gorbunov

12/11/2017, 3:42 AM
So basically a plain module is one of Kotlin/JVM, /JS, /Native?
m

marcinmoskala

12/11/2017, 3:42 AM
This are called regular modules
But I meant plain Kotlin module - regular module in Kotlin that is not directed to any platform. It can be used from Kotlin/JS, Kotlin/JMV and Kotlin/Native
i

ilya.gorbunov

12/11/2017, 3:44 AM
Ok, then I still don't get what is the difference from common. Do plain modules have
apply plugin: 'kotlin-platform-common'
in their gradle files?
m

marcinmoskala

12/11/2017, 3:44 AM
no
It will have only
apply plugin: 'kotlin'
i

ilya.gorbunov

12/11/2017, 3:50 AM
Then these are just Kotlin/JVM modules, they can be used as dependencies only for other JVM projects.
m

marcinmoskala

12/11/2017, 3:50 AM
I need a better example xP
Looks like you just found big error in this article 🙂 👏 I was sure I've seen references to plain Kotlin module but I see now that it can be defined only as Common module
g

gildor

12/11/2017, 5:34 AM
Good article 👍 And additional like for image with Singapore (bridge photo) 🇸🇬
😄 1
View count: 2