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

    juh juh

    08/18/2022, 9:13 AM
    How can I pass compiler arguments to all compile targets in kotlin/multiplatform? To be specific, I want to add
    -Xno-param-assertions argument
    to my release builds to remove runtime null assertions for all the arguments
    o
    • 2
    • 2
  • c

    Ciaran Sloan

    08/18/2022, 12:45 PM
    I have a few modules in my kmm layer but seem to be having an issue with visiblity in my tests. • I have module
    A
    which contains a
    myFunction()
    function in the
    commonTest
    • Module
    B
    is dependent on module
    A
    but I do not have access to
    myFunction()
    in module Bs
    commonTest
    . It is not available for import. Module
    B
    however does have access to module `A`s classes and functions within
    commonMain
    but the issue seems to be in the
    commonTest
    only. Is this expected? Or how can I ensure that each module that implements module
    A
    also gets access to its public classes and functions within
    commonTest
    ?
    g
    • 2
    • 3
  • s

    Sean Proctor

    08/18/2022, 1:22 PM
    I think I'm stuck between two bugs trying to get Android Studio to behave nicely. Since updating to Kotlin 1.7.0, some libraries (moko-resources-compose) don't resolve in the IDE. https://issuetracker.google.com/issues/231701341 adding the workaround suggested there (adding commonMain to the androidMain srcDir) fixes that issue, but then androidMain doesn't seem to be able to resolve anything from commonMain, strangely. I've tried using almost every version of AGP and AS. currently I'm on dolphin with AGP 7.3.0-rc01. Has anyone else had this issue and figured out a working solution?
    m
    e
    • 3
    • 25
  • a

    adjpd

    08/18/2022, 5:34 PM
    Is anyone using 1.7.10 for a KMM project that targets iOS?
    m
    • 2
    • 3
  • j

    juh juh

    08/18/2022, 7:33 PM
    Are there runtime methods to check which platform code is running on?
    l
    s
    +2
    • 5
    • 10
  • j

    juh juh

    08/18/2022, 8:01 PM
    How do I read files from
    Resources
    folder on Kotlin/Multiplatform? Is there a built-in solution, or do I need to use external library?
    m
    s
    • 3
    • 4
  • r

    Raymond Zeng

    08/19/2022, 12:45 AM
    Hey folks, our team is looking into DI solutions for multiplatform, with a focus on compile-time solutions (and Koin as a fallback). We've come across Kotlin-Inject and Kinzhal - are there any other libraries that are currently out there that we should take a look into?
    i
    j
    +3
    • 6
    • 9
  • s

    Sebastian Sellmair [JB]

    08/19/2022, 1:20 PM
    📣 📣 We merged :android: Android Studio ⚡ Electric Eel 🐍 Canary 9 into intellij/master 📣 📣 We expect Android Plugin Updates to be in intellij faster from now on! Also: Android Studio Electric Eel Canary 9 finally seems to have pretty good support for Kotlin/Multiplatform. There were many, many issues fixed that lead to red code in Android Studio :blob-smile-happy: Merging hero: @andrei.kuznetsov
    v
    j
    +3
    • 6
    • 13
  • k

    kenkyee

    08/19/2022, 1:21 PM
    wow…that’s amazing…never thought that would happen :android-dance:
    s
    • 2
    • 2
  • s

    Sachinda Liyanaarachchi

    08/19/2022, 6:05 PM
    hello, I have a question related to KMM shared gradle: There is one library that is related to fritz2 but should be added in commonMain dependencies. But when I run ios it is giving me an error. How can I leave this library in commonMain and exclude it when running ios?
    p
    • 2
    • 2
  • j

    Jeff Lockhart

    08/20/2022, 3:23 PM
    Does it still compile? You could probably add:
    @Suppress("UNINITIALIZED_VARIABLE")
    above the line to hide the IDE error. It's not uncommon that the IDE displays false positive errors that aren't actually compilation errors with KMP.
    x
    s
    • 3
    • 4
  • p

    Pedro Henrique

    08/20/2022, 11:48 PM
    I' ve published a library to Maven that uses Kotlin 1.7.20-Beta + API/Language version of 1.8. With the same settings, using this library through Gradle, it runs fine, but on IntellIJ I get a message saying that 'it is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler'. It only happens on JVM and IDEA-side, since I can build it normally and common and JS platforms aren't giving me this error. Is there any workarounds to this issue? I posted this first on #intellij, but since it is a Multiplatform-related issue, I think it is worth posting here as well.
    b
    • 2
    • 2
  • s

    Smorg

    08/21/2022, 1:37 AM
    Hello here, I added the
    javax.inject
    lib to a multiplatform module in my project but couldn’t import the classes/annotations in my source, and I am trying to understand why. Any pointers would be appreciated. Thanks.
    a
    • 2
    • 1
  • s

    Smorg

    08/21/2022, 1:44 AM
    In addition, has anyone also tried to use Hilt from Android in a kmm project? Wondering how it can be integrated, maybe in full for DI across the project or at least the Android part/modules of the project. Thank you.
    m
    m
    a
    • 4
    • 4
  • m

    Marco Righini

    08/21/2022, 11:08 AM
    Hello everybody, we are having issues with composite build. When you are referencing a class that is in a different gradle module and this module is sharing the same package prefix the IDE shows red import (the ide tries to resolve the symbol in the same module) (Android Studio EE Canary 9). The project builds fine. In case you are interested https://youtrack.jetbrains.com/issue/KTIJ-18903
    o
    • 2
    • 1
  • t

    Tim Ortel

    08/21/2022, 7:49 PM
    Hi! Two months ago I already announced my development of a Gradle Plugin that brings gRPC to Kotlin Multiplatform. I have finally added iOS support. Therefore, it now allows you to make client-side calls from multiplatform code to Android, iOS, JVM and JS targets, as such allowing you to share your network logic. Once again, I would greatly appreciate any feedback on the project! https://github.com/TimOrtel/GRPC-Kotlin-Multiplatform
    p
    • 2
    • 4
  • n

    Noop

    08/22/2022, 8:28 AM
    I tried below, but I got error. How can i do? https://kotlinlang.org/docs/multiplatform-mobile-integrate-in-existing-app.html#make-your-cross-platform-application-work-on-ios
    Build was configured to prefer settings repositories over project repositories but repository 'ivy' was added by build file 'shared/build.gradle.kts'
  • b

    Ben Edwards

    08/22/2022, 10:24 AM
    TLDR: Advice on learning Kotlin for KMM. Hi, just starting my Kotlin journey. I did a couple of weeks doing basic Kotlin tutorials now I'm doing the doing udemy 'Android App Development Masterclass using Kotlin' . My ultimate aim is to develop multiplatform mobile apps (KMM). Thought doing Android apps first was a good approach. I have been programming for over 20 years, mainly using Oracle PL/SQL, quite a bit of bash, and some Ruby, and spend 80 days learning Python (udemy .100 Days of Code: The Complete Python Pro Bootcamp for 2022'). I'm fairly committed and planning on doing 6 hours a day Monday-Friday at least. So my questions are, is this a good approach, and any advice? Also what state is KMM in? It won't be 3 to 6 months before start developing in anger.
    l
    m
    • 3
    • 11
  • b

    Ben Edwards

    08/23/2022, 11:10 AM
    @uli posted https://dev.to/s2engineers/the-future-of-cross-platform-development-kotlin-multiplatform-35n8 in another thread. This was very interesting. It was written 21 Dec 2020. Would love an update. Or maybe there is an actively updated webpage that shows the current state of KMM? PS just read https://blog.jetbrains.com/kotlin/2022/05/kotlin-multiplatform-mobile-beta-roadmap-update/ 31 May 2022. Looking promising.
    u
    • 2
    • 2
  • k

    Kwabena Berko

    08/23/2022, 5:09 PM
    Hi folks, How do I run a custom gradle task that only runs after the build tasks completes in a KMM project?
    tasks.register("copySomething", Copy::class) {
       println("How Do I Run This Task After Build Completes?")
    }
    j
    m
    • 3
    • 15
  • j

    jacksonfdam

    08/24/2022, 10:22 AM
    Guys, I am having some issues with multiple KMM modules depending on other KMM modules.
    a
    • 2
    • 6
  • s

    Sebastian Sellmair [JB]

    08/24/2022, 11:14 AM
    Hey Folks 👋 I was once convinced that sharing code between android + jvm (https://youtrack.jetbrains.com/issue/KT-42466/HMPP-JVM-Android-intermediate-source-set) is underrated. I wanted to write an internal document, making a case for it and trying to raise awareness. However, I currently fail to compile good enough arguments. So: If there is anybody who also thinks this is important, would you mind sharing your thoughts? (You’re also invited if you think this case is not important)
    h
    g
    +4
    • 7
    • 22
  • d

    Don.Robertson

    08/24/2022, 10:56 PM
    • Hi all. Beginner’s question. I have a KMM app that imports (reusable) code from another KMM library (into shared module). The gradle sync works fine. If I build within Android Studio the build fails because it doesn’t find the imports from the shared lib. But if I run the Android emulator the app runs fine (I’ve made visual changes to make sure it is running a current build, and it is definitely executing the code that breaks the build). How is this possible? I’m hoping someone will recognize the strange behavior and give me a clue as to my error with the dependencies.
    j
    p
    s
    • 4
    • 19
  • a

    Asad Mukhtar

    08/25/2022, 6:56 AM
    Hi, everyone can you please let me know, can i use Compose for building Android UI, and swiftUI for IOS in KMM project?
    h
    k
    p
    • 4
    • 6
  • s

    Sreeramktm 27

    08/25/2022, 7:40 AM
    Hi everyone, is there any library to support json handling in KMM. I am trying to have common json implementation across platforms. Found kotlinx.serialization, which can be used in common and android but not in iOS.
    v
    d
    • 3
    • 3
  • f

    Francis Mariano

    08/25/2022, 7:25 PM
    please, where do I find good samples projects using KMP (android/ios/js/backend) ?? thanks a lot
    b
    l
    +3
    • 6
    • 8
  • c

    Ciaran Sloan

    08/26/2022, 10:18 AM
    Has anyone any experience with swifts
    deinit
    function on classes that are extended from a kotlin class? I'm having a weird crash with little info in the stack trace. I've created an open class in my shared module and extending that class in Swift. I want to perform some operation in the
    deinit
    function (a cleanup of sorts), but im getting a crash when trying to access a protected property of the base class from the deinit function. I'm suspecting that possibly this object no longer exists? But I can't get enough information from the stacktrace to determine this
  • v

    Vitor Hugo Schwaab

    08/26/2022, 7:54 PM
    So.... composite builds + hierarchical project structure = IDE not able to solve common code references, right? I have a structure like so:
    AndroidAppProject
    -app
    -appModuleA
    -appModuleB
    -multiPlatformProject 
     |-multiPlatformModuleA
     |-multiPlatformModuleB
    multiPlatformProject and its contents are included via
    includeBuild
    . Stuck on Kotlin 1.6.10 because of this. I came across this super creative work-around to trick the IDE into thinking we're using 1.6.10 in order to keep it working, but it didn't do the trick for me. Anyone else working around this issue?
    n
    • 2
    • 2
  • f

    fathony

    08/27/2022, 5:06 AM
    Hi, I'm trying to implements an interface that returns Flows on swift, something like
    callbackFlow {}
    in Kotlin. For example:
    // Kotlin common
    interface Repository {
        fun location(): Flow<LatLng>
    }
    // Kotlin android
    class AndroidRepository : Repository {
        override fun location(): Flow<LatLng> = 
            callbackFlow {
                // some implementation 
            }
    }
    How should I implements those on swift?
    // Swift iOS
    class IosRepository : Repository {
        func location() -> // how to?
    }
    I'm already looking at the topics but unable to find anything that solves above issue. Am I missing something here?
    h
    • 2
    • 2
  • m

    miqbaldc

    08/27/2022, 7:16 AM
    [v] System                                           
        OS: macOS (11.6)
        CPU: Apple M1
    [v] Java
        Java (openjdk version "11.0.14" 2022-01-18 LTS)
        Location: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
        
        JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
        
        * Note that, by default, Android Studio uses bundled JDK for Gradle tasks execution.
              Gradle JDK can be configured in Android Studio Preferences under Build, Execution, Deployment -> Build Tools -> Gradle section
        
    [v] Android Studio
        Android Studio (2021.2)
        Location: /Applications/Android <http://Studio.app|Studio.app>
        Bundled Java: openjdk 11.0.12 2021-07-20
        Kotlin Plugin: 212-1.7.10-release-333-AS5457.46
        Kotlin Multiplatform Mobile Plugin: 0.3.3(212-1.7.0-RC-release-217-IJ)-104
        
    [v] Xcode
        Xcode (13.2.1)
        Location: /Applications/Xcode.app
        
    [v] Cocoapods
        ruby (ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin20])
        
        ruby gems (3.3.11)
        
        cocoapods (1.11.3)
        
        cocoapods-generate (2.2.2)
        
    Your system is ready for Kotlin Multiplatform Mobile Development!
    a
    m
    • 3
    • 4
Powered by Linen
Title
m

miqbaldc

08/27/2022, 7:16 AM
[v] System                                           
    OS: macOS (11.6)
    CPU: Apple M1
[v] Java
    Java (openjdk version "11.0.14" 2022-01-18 LTS)
    Location: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
    
    JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
    
    * Note that, by default, Android Studio uses bundled JDK for Gradle tasks execution.
          Gradle JDK can be configured in Android Studio Preferences under Build, Execution, Deployment -> Build Tools -> Gradle section
    
[v] Android Studio
    Android Studio (2021.2)
    Location: /Applications/Android <http://Studio.app|Studio.app>
    Bundled Java: openjdk 11.0.12 2021-07-20
    Kotlin Plugin: 212-1.7.10-release-333-AS5457.46
    Kotlin Multiplatform Mobile Plugin: 0.3.3(212-1.7.0-RC-release-217-IJ)-104
    
[v] Xcode
    Xcode (13.2.1)
    Location: /Applications/Xcode.app
    
[v] Cocoapods
    ruby (ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin20])
    
    ruby gems (3.3.11)
    
    cocoapods (1.11.3)
    
    cocoapods-generate (2.2.2)
    
Your system is ready for Kotlin Multiplatform Mobile Development!
a

Aditya Kurkure

08/28/2022, 8:11 AM
Have you tried the solutions listed here? https://kotlinlang.org/docs/native-cocoapods.html#possible-issues-and-solutions
m

miqbaldc

08/28/2022, 12:27 PM
Unfortunately, I'm using Reguler framework (not currently using cocoapods) and running the
embedAndSignAppleFrameworkXcode
m

Meherdatta Chepuri

03/09/2023, 11:57 PM
Did it work for you?
m

miqbaldc

03/10/2023, 2:43 AM
still not works unfortunately
View count: 10