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

    Gabriel Feo

    11/20/2019, 3:35 PM
    Hi! I'm starting out with multiplatform, but IDEA is pointing out usages of java packages in my code as unresolved references, even though the project compiles (any
    java.*
    reference). Has anyone run into this?
    r
    s
    e
    • 4
    • 12
  • d

    Dominaezzz

    11/20/2019, 3:51 PM
    So I've included,
    testImplementation(kotlin("test-common"))
        testImplementation(kotlin("test-annotations-common"))
        testImplementation(kotlin("test"))
        testImplementation(kotlin("test-junit"))
    (which works for multi-platform) in my Kotlin/JVM project but I can't resolve the
    kotlin.test.Test
    annotation. Is this not supported?
    j
    i
    • 3
    • 8
  • a

    Andreas Jost

    11/20/2019, 7:32 PM
    expect interface A {
       fun doSomething()
    }
    actual interface A {
       actual fun doSomething() { /*do sth. */ }
    }
    This code causes an error, because the expected function is abstract by default and the actual function has an implementation, which means that modality is different. Can I somehow define the expect function as non-abstract? Usually you would give a function of an interface a body to make it non-abstract. If you do that, the error at the actual declaration is gone, but expected declarations must not have bodies, so that's another error.
    k
    a
    • 3
    • 6
  • h

    hallvard

    11/20/2019, 7:45 PM
    @JoakimForslund: Using the
    maven-publish
    plugin, I do this, which works well for me:
    publishing {
        publications {
            maven(MavenPublication) {
                pom {
                    name = 'projectname'
                    description = 'Whatever ...'
                }
                artifactId project.name
                groupId project.group
                version project.version
    
                // Without the following line, these gradle build scripts publish no jar to maven
                // We have not succeeded in finding out why (as of May 2019)
                from components.java
            }
        }
        repositories {
            maven {
                def releasesRepoUrl = "(url here)"
                def snapshotsRepoUrl = "(url here)"
                url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
                credentials {
                    username mavenUser
                    password mavenPassword
                }
            }
        }
    }
    j
    • 2
    • 3
  • k

    Kris Wong

    11/20/2019, 8:54 PM
    IDEA is showing a new error with 1.3.60 on all my unit test method names: "Name contains illegal chars that can't appear in JavaScript identifier"
    👀 2
    g
    a
    +2
    • 5
    • 8
  • b

    Ben Ryan

    11/20/2019, 9:22 PM
    Hi everyone. Ever since updating my kotlin plugin to 1.3.60 I cannot run selected common tests using the green triangle, it says "No tasks available". Anyone else having this problem?
    s
    k
    +3
    • 6
    • 13
  • b

    Big Chungus

    11/21/2019, 10:02 AM
    Just released KVDOM MVP: https://gitlab.com/lt.petuska/kvdom/-/releases What's KVDOM you ask? It's an MPP implementation of virtual DOM available for js and wasm targets (also common module targeting them both). In addition to that, kvdom-dom module exposes some basic DOM bindings to kotlin-wasm directly and can be used as a standalone lib.
    👍 2
    👏 2
    r
    • 2
    • 4
  • i

    Indrih17

    11/21/2019, 12:10 PM
    Hello. I am trying to make a small simple multiplatform library. https://github.com/indrih17/teaco/blob/master/teaco-mpp/build.gradle.kts I had a problem that klib files for iOS are not generated when the publishToMavenLocal task starts, and there are no publishing tasks for iOS in Gradle tasks. Please tell me what I'm doing wrong, I've been struggling with this problem for two days now.
    i
    • 2
    • 6
  • s

    Sylvain Patenaude

    11/21/2019, 4:19 PM
    From an SDK consumer viewpoint, would it be preferred to return an
    array
    of strings or a
    collection
    of strings? Potential consumers (other than Koltin itself) could be Java, Swift, Objective-C, React Native, Xamarin, etc.
    k
    s
    • 3
    • 9
  • b

    Big Chungus

    11/21/2019, 5:17 PM
    Does anyone have an example of setting up gradle to publish MPP lib to bintray with metadata?
    s
    m
    m
    • 4
    • 7
  • f

    Fabio Bombardi

    11/21/2019, 8:08 PM
    Hi guys! Is it possible to debug (e.g. setting breakpoints in kotlin code) an mpp library using AppCode while running the iOS project that uses the framework generated from this library?
    k
    • 2
    • 10
  • v

    vanniktech

    11/21/2019, 11:52 PM
    Is there something similar to OkHttp's https://square.github.io/okhttp/4.x/okhttp/okhttp3/-authenticator/ for ktor? Basically, a mechanism to manually refresh a token and re-fire the same request
    m
    • 2
    • 4
  • k

    Kurt Renzo Acosta

    11/22/2019, 2:47 AM
    Hello! Has anyone encountered an
    unrecognized selector sent to instance
    in Kotlin/Native for iOS? I have a presenter which has use cases and I just use a service locator to try and use them.
    @ThreadLocal 
    object ServiceLocator {
        val myObject = MyObject()
    }
    
    class MyPresenter(val myView: MyView, val myObject: MyObject) {
        ...
    }
    class ViewController: UIViewController, MyView {
        let presenter = MyPresenter.init(myView: self, myObject, ServiceLocator.init().myObject)
        ...
    }
    b
    m
    • 3
    • 4
  • l

    louiscad

    11/22/2019, 9:06 AM
    Just fixed red code bug in the IDE (where I had a multiplatform module depending on another one, with an Android target) by adding
    kotlin.mpp.enableGranularSourceSetsMetadata=true
    to my
    gradle.properties
    (requires Kotlin 1.3.60). 🎉 🎉 💪 Thanks for the improvements!
    :kotlin-flag: 3
    👏 5
    a
    d
    • 3
    • 5
  • c

    Cristián Arenas

    11/22/2019, 8:50 PM
    When I compile my project for iOS, the
    .h
    includes a lot of internal Kotlin stuff (like
    KotlinNumber
    ,
    KotlinUByte
    ,
    Sqldelight_runtimeTransacter
    , etc), how can I stop it from doing that? I just want it to expose what I mark as
    public
    m
    k
    • 3
    • 8
  • m

    mbonnin

    11/22/2019, 9:01 PM
    Do you use Android Studio or IntelliJ to develop an Android App that has some multiplatform modules ?
    k
    s
    • 3
    • 8
  • n

    niqo01

    11/22/2019, 10:49 PM
    Is there an equivalent of java CopyOnWriteArrayList in common code? I am trying to find an easy way to share a mutable collection across threads in common code.
    a
    k
    • 3
    • 7
  • s

    SrSouza

    11/23/2019, 11:24 AM
    Hi guys, three is no easy way to have a global native target? I was looking at Coroutines, and its kinda a hack what they do https://github.com/Kotlin/kotlinx.coroutines/blob/master/gradle/compile-native-multiplatform.gradle Any better way to achieve that? Any plan for in the future have a global native target?
    e
    • 2
    • 1
  • v

    vanniktech

    11/23/2019, 6:12 PM
    Has anyone been able to convert a file from an iOS system into a KotlinByteArray? I want to upload an image using ktor and ByteArray is the common denominator between the platforms. Android side is already working.
    ➕ 1
    m
    k
    • 3
    • 4
  • s

    serebit

    11/23/2019, 7:18 PM
    What's the status of code generation for multiplatform projects where the code to be generated needs to be in the common source set?
    r
    • 2
    • 3
  • s

    Shan

    11/24/2019, 7:48 AM
    Does anyone have an example of how to set up MPP for javascript tests? I read in the docs that
    At this point, test tasks for Kotlin/JS are created but do not run tests by default; they should be manually configured to run the tests with a JavaScript test framework.
    but I am not quite sure about how to go about this..
    r
    • 2
    • 2
  • s

    SrSouza

    11/24/2019, 3:39 PM
    Anyone know what is this project do exacly? https://github.com/Kotlin/kotlinx.team.infra
    d
    f
    • 3
    • 2
  • k

    kpgalligan

    11/24/2019, 5:19 PM
    Anybody use Stately collections? We’re starting to look at replacing them and want to better understand use cases.
    e
    b
    q
    • 4
    • 33
  • s

    Shan

    11/25/2019, 1:52 AM
    Anyone know why when I try to call Java classes from JvmTest I get an
    Unresolved Reference
    error? Project structure is like
    proj
      |_ commonMain
      |_ commonTest
      |_ jvmMain
          |_ kotlin
              |_ com.my.package.keys
                  |_ KeyPairJ.java
      |_ jvmTest
          |_ kotlin
              |_ com.my.package
                  |_ KeyPairTest
    Getting this error every time I try to run a test:
    e: ../src/jvmTest/kotlin/com/my/package/KeyPairTest.kt: (13, 19): Unresolved reference: KeyPairJ
    My build file is set up like so
    //ommitted some things
    
    kotlin {
        jvm()
        js()
    
        sourceSets {
            //omitted some stuff
            val jvmMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-jdk8"))
                    //other stuff- ktor, coroutines, etc.
                }
            }
            val jvmTest by getting {
                kotlin("test")
                kotlin("test-junit")
            }
        }
    }
    Very confused here.. I can call code from
    commonMain
    fine, just not from
    jvmMain
    🤔
    r
    • 2
    • 3
  • c

    Casey Brooks

    11/25/2019, 7:32 PM
    Has anyone successfully upgraded to 1.3.60 and compiled an iOS library? On 1.3.50, my project worked fine, but in 1.3.60 I get an error on the
    linkFramework
    tasks:
    Task :linkMobileSharedDebugFrameworkIos
    e: Compilation failed: org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor@21f27bb5 is not bound
    
     * Source files:
     * Compiler version info: Konan: 1.3.60 / Kotlin: 1.3.60
     * Output kind: FRAMEWORK
    
    e: java.lang.IllegalStateException: org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor@21f27bb5 is not bound
            at org.jetbrains.kotlin.backend.common.descriptors.WrappedDeclarationDescriptor.getOwner(WrappedDescriptors.kt:98)
            at org.jetbrains.kotlin.backend.common.descriptors.WrappedPropertyDescriptor.getReturnType(WrappedDescriptors.kt:816)
            ...
    s
    a
    • 3
    • 8
  • n

    Nicholas Bilyk

    11/25/2019, 9:53 PM
    I'm having trouble with transitive runtime dependencies from a multiplatform library project. My library has runtime dependencies that need to be used by the consumer. Example:
    // My library
    kotlin.sourcesets.named("jvmMain") {
      dependencies {
         runtimeOnly("$lwjglGroup:$lwjglName:$lwjglVersion:natives-$os")
      }
    }
    However, the consumer can't see this dependency unless it also specifies the runtimeOnly. Is there a way to make this apply without the consumer of my library needing to specify it explicitly?
    d
    • 2
    • 4
  • n

    niqo01

    11/25/2019, 11:04 PM
    I would expect those kind of issues to be caught at compile time.
    r
    k
    e
    • 4
    • 5
  • a

    Akhil Sunny

    11/26/2019, 10:28 PM
    Hi , I have a kotlin mpp with android, js and iOS outputs. Could you please suggest the unit testing code coverage tools I can use for Kotlin mpp project ?
    v
    e
    • 3
    • 4
  • s

    Sylvain Patenaude

    11/27/2019, 7:52 PM
    Is there a multiplatform way in Kotlin to figure out the endianness of bytes? I have to know to reverse the order if ncessary.
    i
    r
    d
    • 4
    • 28
  • n

    niqo01

    11/28/2019, 2:45 AM
    I am seeking for advice, best practice to handle exceptions where the logic to handle exceptions is in common code and the exceptions are thrown by SDKs implemented in each platforms. I would like to have logic like if an exception is of one type then do X otherwise do Y.
    s
    g
    • 3
    • 5
Powered by Linen
Title
n

niqo01

11/28/2019, 2:45 AM
I am seeking for advice, best practice to handle exceptions where the logic to handle exceptions is in common code and the exceptions are thrown by SDKs implemented in each platforms. I would like to have logic like if an exception is of one type then do X otherwise do Y.
s

Sam

11/28/2019, 3:04 AM
Can you declare your exceptions in common code? Then your platform code can just throw them as needed.
n

niqo01

11/28/2019, 4:01 AM
Is the practice of declaring exception in common code and mapping the SDK generated ones into those the recommended approach? I should look into what ktor is doing
s

Sam

11/28/2019, 4:02 AM
Maybe a more concrete example of a problem you're trying to solve would be helpful.
n

niqo01

11/28/2019, 4:23 AM
I have several use cases. One of them is a presenter in common code which execute various tasks with one of them being an API call. On the jvm various exception can be returned extending
<http://java.io|java.io>.IOException
or not. I could catch the specific IOException related to no connectivity and ask the user to check their network settings, I could also catch the IOException related to network issues and ask the user to retry and just re-throw if this is not an IOException. Another use case is about the Firestore database which offers and SDK for each platform. Requesting cache data which does not exist return FirebaseException with a specific property which I would like to capture and run different logic based on the cause. I actually don't see any other ways than creating my own common code exception and map each platform one to the common one.
g

Gabriel Feo

11/30/2019, 1:39 AM
Yeah, I think you'll have to map an
actual typealias
to the
java.io.IOException
👍 1
View count: 9