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

    Kurt Renzo Acosta

    12/06/2019, 9:54 AM
    Hello! Was anyone able to share ViewModels/Presenters between Android and iOS? I've been trying for a while but can't seem to get a solution. Here's my setup so far.
    class MyViewModel(private val useCase: UseCase) : ViewModel() {
        fun doSomething() {
            useCase()
            liveData.value = "New Value"
        }
    }
    class MyPresenter(private val myView: MyView, private val useCase: UseCase) : BasePresenter() {
        fun doSomething() {
            useCase()
            myView.updateView("New Value")
        }
    }
    I wanted to extract the common code between them so initially, I created an expected class and wanted something like this:
    expect class MyCommonClient(useCase: UseCase) {
        fun doSomething() {
            useCase()
            success("New Value")
        }
        
        expect fun success(newValue: String)  
    }
    But then,
    Expected declaration must not have a body
    So I tried out a class:
    abstract class MyCommonClient(useCase: UseCase) {
        fun doSomething() {
            useCase()
            success("New Value")
        }
        
        abstract fun success(newValue: String)  
    }
    But now, I'm having multiple supertypes
    class MyViewModel : ViewModel(), MyCommonClient() <--- Error
    Am I running towards a wall or is there any workaround or pattern to achieve something like this? Thanks in advance!
    t
    a
    +3
    • 6
    • 14
  • f

    fuddi

    12/06/2019, 11:18 AM
    Hi 🙂 I’ve finished the Kotlin Hands-on “Targeting iOS and Android with Kotlin Multiplatform” -> https://play.kotlinlang.org/hands-on/Targeting%20iOS%20and%20Android%20with%20Kotlin%20Multiplatform/01_Introduction 🎉 🤪 Now I want to look at using multiplatform libraries like the ktor-http-client https://ktor.io/clients/index.html. Do anyone knows some other good hands-on labs for that? 🙏
    a
    d
    +2
    • 5
    • 5
  • j

    Joris PZ

    12/07/2019, 6:53 PM
    Hi all, I'm participating in Advent of Code (https://adventofcode.com/2019) this year again, and just like last year, I'm trying to write my solutions in Kotlin common code, compile to bytecode, JS and native (MinGW), and do some rudimentary performance comparisons. Now, for today's puzzle I have added coroutines, and suddenly my MPP project fails to build. I have fiddled with absolutely everything - kotlin plugin version, gradle version, JDK version, library versions, in every permutation I could think off, but my build keeps failing with the completely unhelpful
    Execution failed for task ':linkDebugExecutableMingw'.
    > Process 'command 'C:\dev\java\openjdk-11.0.2\bin\java.exe'' finished with non-zero exit value 1
    Before I throw in the towel and just continue on JVM alone, if anyone would be willing to take a look to see what I could be doing wrong it would be much appreciated. The repo is https://github.com/jorispz/aoc-2019, the project is pretty much standard as generated by IDEA, with the addition of the coroutine depenendencies.
    j
    • 2
    • 6
  • m

    Marc Knaup

    12/08/2019, 1:05 PM
    I’m working out a multiplatform library design right now where I would like objects to reference to each other in cycles. Would that cause problems (like leaks) on any of the supported platforms?
    e
    • 2
    • 1
  • j

    Joey

    12/09/2019, 6:43 AM
    Hi guys! I already implemented coroutine for jdk8 in my common dependencies. But i can't seem to use
    GlobalScope.future
    P.S. Im developing a library for android and iOS
    s
    • 2
    • 3
  • r

    ribesg

    12/09/2019, 11:15 AM
    I’m trying to use
    @Parcelize
    in a multiplatform library, using `expect`/`actual` on
    @Parcelize
    and
    Parcelable
    , but I encounter a very weird error when using the
    kotlin.android.extensions
    plugin on one library: “This class does not have a constructor” on a
    data class
    . Anyone encountered this?
    i
    • 2
    • 4
  • b

    Boris Dudelsack

    12/09/2019, 12:47 PM
    I would appreciate some help. Repo: https://github.com/bdudelsack/kotlin-fullstack-example
    n
    • 2
    • 8
  • r

    Rak

    12/09/2019, 1:03 PM
    1. we use rxjava in our code, is there a suitable replacement? Is the current version of flow MPP-compatible?
    d
    s
    +2
    • 5
    • 6
  • r

    Rak

    12/09/2019, 1:03 PM
    2. What about iOS? How to include them? Any advice?
    s
    k
    c
    • 4
    • 3
  • p

    Piasy

    12/10/2019, 4:27 AM
    Hello guys, I have a question: I want to compile my commonMain and iosMain kotlin code into a static library, I achieve this target with gradle plugin, but my problem is, I don't know how to implement an abstract kotlin class in Objective-C and pass it to kotlin, because when I compile kotlin code to static library, all stuff are C struct. Here is my kotlin abstract class:
    abstract class ConfEvents {
      open fun onPeerJoined(uid: String) {}
    }
    Here is the generated C header:
    struct {
      libAvConf_KType* (*_type)(void);
      libAvConf_kref_com_piasy_avconf_ConfEvents (*ConfEvents)();
      void (*onPeerJoined)(libAvConf_kref_com_piasy_avconf_ConfEvents thiz, const char* uid);     
    } ConfEvents;
    If I compile kotlin code into framework, then
    ConfEvents
    would have a Objective-C interface, then I can extend it and pass it to kotlin.
    c
    a
    • 3
    • 44
  • c

    Cristián Arenas

    12/10/2019, 7:19 PM
    How can I add a special extension to a class only for Android? In iOS, this worked:
    fun MyType.newMethod(x: NSSomething) {}
    I could call it from iOS with the appropriate type. But if I add the equivalent in Android, it isn’t callable.
    k
    k
    • 3
    • 14
  • g

    gaetan

    12/10/2019, 10:49 PM
    I try to move data2viz to the “new” MPP plugin. We are currently targetting JS, JavaFx and Android. I don’t find any example of a project with the new MPP plugin that does this. Is it possible? Does anyone has a project that I could use as an example?
    d
    r
    n
    • 4
    • 4
  • j

    Joey

    12/11/2019, 5:10 AM
    Hi guys, i have this function inside my kotlin shared library.
    suspend fun fetchUsers(): List<String> {
            val response = client.get<JsonObject> { url("$baseUrl/heartbeat.json") }
            val userIds = response.keys.toList()
            return userIds
        }
    Now im trying to implement it in a pure old java project. I enabled the kotlin plugin in this project and created this function:
    fun fetchUsersFromKtLib(): List<String> {
        val api = HeartbeatApi()
        val users = GlobalScope.future { api.fetchUsers()  }
        return users.get()
    }
    Now everytime im calling this
    fetchUsersFromKtLib
    function, there is a jank in my UI (a freeze). Im trying to solve this problem for about 3 days now. So far this is the cleanest way i called the function from the kotlin shared library. What can you suggest to avoid any UI freeze? Thanks guys!
    y
    m
    • 3
    • 11
  • d

    dambakk

    12/11/2019, 8:16 AM
    Hi! I have started a new mp project in IDEA (kotlin version 1.3.61) and added dependency for coroutines (
    1.3.2
    ) and implemented an iOS dispatcher as explained by @salomonbrys in the kotlinconf workshop. The
    actual
    on the android side works fine, but I get an unresolved reference on the
    CoroutineDispatcher
    import on the ios side. When running the gradle assemble i get an error saying
    The abi versions don't match. Expected '[17]', found '14'
    . Any idea what causes this and how to resolve it?
    a
    m
    • 3
    • 4
  • j

    Jan Stoltman

    12/11/2019, 9:25 AM
    Hey, I'm looking for ktor setup example for ios
    k
    • 2
    • 2
  • m

    Miguel Fermin

    12/11/2019, 9:46 PM
    Hi everyone, I'm working on a native Android Library (aar) to make available to the Android UI team, who doesn't have access to the source code. I want to use a Kotlin multiplatform generated aar inside this library. I had followed the steps to add the main android library to an android app (to simulate what the UI team will have to do) as described here - https://developer.android.com/studio/projects/android-library, and it worked fine when it was just the main library. I then added the mpp generated aar to the main android library, following the same steps (https://developer.android.com/studio/projects/android-library) but the public classes aren't visible. I tried doing the same but using non-mpp libraries (aar), and I can at least see the nested libraries classes from the top level lib.
    app
    	|
    	|_ LibA 
    			|
    			|_ LibB (mpp)
    Next thing I have in mind is trying to generate .jar libraries from Kotlin mpp and see if that works Any ideas would be highly appreciated.
    k
    m
    • 3
    • 14
  • s

    saket

    12/12/2019, 3:45 AM
    Replacing
    iosX64("ios")
    with
    targetFromPreset(presets.iosX64, 'ios')
    is resulting in a strange error that I can't figure out. I'm already using Xcode 11 (currently downloading 11.3 if that changes anything). Does this look familiar to anyone?
    > Task :shared:linkDebugFrameworkIos
    error: Invalid record (Producer: 'LLVM8.0.0svn' Reader: 'LLVM APPLE_1_1100.0.33.8_0')
    1 error generated.
    e: Compilation failed: The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ command returned non-zero exit code: 1.
    output:
    
     * Source files:
     * Compiler version info: Konan: 1.3.60 / Kotlin: 1.3.60
     * Output kind: FRAMEWORK
    
    e: org.jetbrains.kotlin.konan.KonanExternalToolFailure: The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ command returned non-zero exit code: 1.
    k
    i
    • 3
    • 5
  • s

    saket

    12/12/2019, 7:08 AM
    Uh… I think I got confused with something while juggling many different kind of changes. Replacing
    iosX64()
    with
    fromPreset(presets.iosX64)
    is fine, but the actual error is coming from these lines:
    framework {
      // Disable bitcode embedding for the simulator build.
      if (!buildForDevice) {
        embedBitcode("disable")
      }
    }
    i
    k
    • 3
    • 16
  • s

    saket

    12/12/2019, 7:08 AM
    cc @ilya.matveev
    • 1
    • 2
  • k

    Konstantin Tskhovrebov

    12/12/2019, 3:48 PM
    Hello, is there a way in Kotlin to use property delegates for data classes in constructor? I want to create something like Swift's
    Property Wrapper
    https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617
    k
    b
    • 3
    • 15
  • t

    trickybits

    12/12/2019, 9:48 PM
    Does anyone know if there's a list matching ABI version code to version numbers? Kinda hard to figure out " The abi versions don't match. Expected '[17]', found '9'" otherwise 😄
    m
    • 2
    • 2
  • d

    Dmitri Sh

    12/13/2019, 1:58 AM
    Anyone targeting watchOS and tvOS along with iOS in one project? I can't find any reference projects to do that. 1.3.6 is supposed to support all of them but there is not a single sample project on how to configure the build 😥
    b
    • 2
    • 8
  • j

    Joey

    12/13/2019, 3:56 AM
    Any way to solve this incompatibility issues of java and kotlin?
    a
    r
    d
    • 4
    • 4
  • a

    Arkadii Ivanov

    12/13/2019, 4:50 PM
    We have published a new article "Continuous delivery for your Kotlin Multiplatform library": https://badootech.badoo.com/continuous-delivery-for-your-kotlin-multiplatform-library-3ab5ad5cba59
    👍 8
    :thumbsup_all: 1
    a
    m
    +3
    • 6
    • 6
  • j

    jk2018

    12/13/2019, 6:22 PM
    Kotlin does not have certain interfaces & classes, like Queue, LinkedList ( because on JVM it uses Java's implementations ), but I'm wondering if there's a place were these are (to be?) defined? e.g. is there a standard, common Queue interface to be used by MP?
    a
    • 2
    • 2
  • k

    kpgalligan

    12/13/2019, 7:40 PM
    Any good examples of a multiplatform project that inteops with jni on the android side? Essentially looking for multiplatform talking to shared c/c++
    s
    j
    • 3
    • 7
  • a

    Aleksey Chugaev

    12/13/2019, 9:48 PM
    Hi All, I am trying to use mt coroutines in my project but cannot resolve
    newSingleThreadContext
    in iosMain • I have built https://github.com/Kotlin/kotlinx.coroutines/tree/native-mt and installed it locally • added
    kotlin.mpp.enableGranularSourceSetsMetadata=true
    to gradle.properties • commonMain depends on
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2-native-mt-SNAPSHOT"
    • iosMain depends on
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.2-native-mt-SNAPSHOT"
    • using kotlin 1.3.61 Am I missing something? P.S. I have also tried to build https://github.com/kpgalligan/MTCoroutines locally and it worked.
    k
    • 2
    • 7
  • p

    pabl0rg

    12/14/2019, 7:18 AM
    Interesting developments in cross-platform UI workflow: This app can import a design from Sketch and generate UI code for Android (paid), iOS (paid) and Flutter (free) https://supernova.io/pricing It would be awesome if Kotlin Multiplatform common code could easily connect to such native UIs as are generated by supernova. This would level the playing field in sone regards vd Flutter, with the benefits of Kotlin and of being native. Also, Adobe XD will support Flutter code generation (for free, due to Google support) in “early 2020”. https://theblog.adobe.com/xd-flutter-plugin-generate-dart-code-design-elements/
    t
    • 2
    • 1
  • d

    Dmitri Sh

    12/15/2019, 5:55 AM
    Looks like ktor http client is not available for watchOS? Is that correct or I am just missing something?
    • 1
    • 1
  • r

    Ramadan Al.

    12/15/2019, 2:47 PM
    Hey guys, stuck at this issue for a day. Any solution?
    Task 😒hared:linkSharedDebugFrameworkIos
    e: Compilation failed: Expected 'BaseContinuationImpl.invokeSuspend' but was 'org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@1f36969b' * Source files: * Compiler version info: Konan: 1.3.61 / Kotlin: 1.3.60 * Output kind: FRAMEWORK e: java.lang.AssertionError: Expected 'BaseContinuationImpl.invokeSuspend' but was 'org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@1f36969b' at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.getContinuation(IrToBitcode.kt:1936) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateFunctionCall(IrToBitcode.kt:2055) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateCall(IrToBitcode.kt:1795) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateExpression(IrToBitcode.kt:784) ...
    k
    a
    • 3
    • 8
Powered by Linen
Title
r

Ramadan Al.

12/15/2019, 2:47 PM
Hey guys, stuck at this issue for a day. Any solution?
Task 😒hared:linkSharedDebugFrameworkIos
e: Compilation failed: Expected 'BaseContinuationImpl.invokeSuspend' but was 'org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@1f36969b' * Source files: * Compiler version info: Konan: 1.3.61 / Kotlin: 1.3.60 * Output kind: FRAMEWORK e: java.lang.AssertionError: Expected 'BaseContinuationImpl.invokeSuspend' but was 'org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl@1f36969b' at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.getContinuation(IrToBitcode.kt:1936) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateFunctionCall(IrToBitcode.kt:2055) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateCall(IrToBitcode.kt:1795) at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateExpression(IrToBitcode.kt:784) ...
Issue in github: https://github.com/JetBrains/kotlin-native/issues/3682
k

kpgalligan

12/15/2019, 4:55 PM
Responded in the issue
👍 1
r

Ramadan Al.

12/15/2019, 5:07 PM
@kpgalligan thank you for your response, The code is pretty big. But i will try your suggestion and remove some of the latest changes i made and see if it work.
a

Artyom Degtyarev [JB]

01/13/2020, 12:25 PM
Hello @Ramadan Al. ! Any updates here?
r

Ramadan Al.

01/13/2020, 2:29 PM
The issue was in my case is the usage of a UseCase class that might have ktor response or exception.
I think you have to look in the code to find it.
a

Artyom Degtyarev [JB]

01/13/2020, 2:32 PM
Okay then, and you managed to deal with it? Can I close the GitHub issue as obsolete?
r

Ramadan Al.

01/13/2020, 2:33 PM
Yes
👍 1
View count: 3