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

    Tobi

    02/11/2019, 4:25 PM
    Hey folks, after upgrading my multiplatform project to kotlin 1.3.20 and ktor 1.1.2 I am running into this exception when running my tests under common/androidTest. The problem just occurs when running the tests.
    java_lang_NoClassDefFoundError__io_ktor_client_features_json_JsonFeature.txt
    s
    • 2
    • 5
  • t

    Tobi

    02/12/2019, 9:06 AM
    I am running into a
    java.lang.NoClassDefFoundError: kotlinx/serialization/json/Json
    when executing tests in a multiplatform project. Any help would be much appreciated 🙏
    h
    • 2
    • 3
  • d

    Dico

    02/12/2019, 7:38 PM
    what is the point / use of the
    metadata
    artifact? I was trying to add
    com.soywiz:klock
    to my multiplatform project, and I was struggling because I couldn't find a recent version for which all artifacts are present in the maven repository. I cloned its source and installed it to my local maven repository. The
    klock
    artifact is not present, but I tried adding
    klock-metadata
    as a dependency. It worked in one subproject, although I didn't try compiling, but not in another. @Deactivated User
    s
    • 2
    • 7
  • g

    galex

    02/13/2019, 10:57 AM
    Could we hope for annotation processing one day in non-jvm projects? Is that too far fetched?
    👍 2
    i
    o
    s
    • 4
    • 10
  • i

    Ivan

    02/13/2019, 2:40 PM
    Hi, guys cant build project for ios after plugin update from 1.3.0 to 1.3.21 error: Compiler version info: Konan: 1.1.2 / Kotlin: 1.3.21 tried to put konan as dependency into gradle, does not worked for me
    n
    • 2
    • 2
  • l

    louiscad

    02/13/2019, 7:04 PM
    Hi, I have one Java file that can't be converted to Kotlin due to Kotlin limitation (hiding a java field in a subclass by using the same name), and I'd like to migrate the library having this class to the Kotlin multiplatform plugin (even though I would just publish for Android for that module). Is there a way to add java compilation for this file so it's included in the final aar?
    j
    • 2
    • 1
  • c

    Chris Zhang

    02/13/2019, 7:27 PM
    Hi folks, can’t seem to find any documentation on publishing a “common” artifact via the kotlin-multiplatform plugin. Are there any example projects doing so?
    s
    k
    h
    • 4
    • 7
  • s

    sitepodmatt

    02/14/2019, 4:34 AM
    Is there a uniform jvm/js/native Date library in the works as part of libstd?
    g
    • 2
    • 2
  • b

    basher

    02/14/2019, 7:40 PM
    Are there any mpp mocking libraries out there yet?
    🇳🇴 3
    😢 2
    g
    • 2
    • 4
  • m

    Matouš Skála

    02/16/2019, 9:50 PM
    Is there an example how to access android sdk from androidMain sources in MPP? I have applied
    com.android.library
    plugin, but during compilation I still get
    Unresolved reference: android
    when trying to access classes from android sdk. Do I miss something here? https://github.com/MattSkala/kotlin-examples/commit/22477f5b24badb23d158f1dd3760ee2780d01a9a
    r
    • 2
    • 2
  • s

    subin s v

    02/17/2019, 12:33 PM
    Hey guys, Just updated the 'kotlin-multiplatform' plugin from 1.3.10 and 1.3.21.. Also updated the compilations.main.outputkinds to new binaries block.. And noticed the generated iOS target framework size has increased.. Previously it was Debug Framework = 4.3MB Release Framework = 2.8MB After update Debug Framework = 4.8MB Release Framework = 7.1MB Debug version contains (Arm32, Arm64, x64) Release version contains (Arm32, Arm64) Also now release framework size is greater than the Debug version. Why is this happening. Am I doing something wrong..
    iOS_target_framework_size_increased.groovy
    j
    s
    • 3
    • 5
  • d

    dewildte

    02/17/2019, 5:12 PM
    Hey folks I am totally new to this stuff and am banging my head against an issue. in my
    jvmMain
    project I keep getting a unresolved reference to ktor's
    HttpClient
    class that exists in
    commonMain
    .
    a
    j
    • 3
    • 10
  • r

    ribesg

    02/18/2019, 10:34 AM
    How do you create an iOS Framework with multiple architectures?
    s
    • 2
    • 1
  • r

    ribesg

    02/18/2019, 1:36 PM
    I’m trying to publish my mpp lib to my local maven repo and I get
    > Task :generateMetadataFileForAndroidReleasePublication FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':generateMetadataFileForAndroidReleasePublication'.
    > org.jetbrains.kotlin.gradle.plugin.mpp.HierarchyAttributeContainer cannot be cast to org.gradle.api.internal.attributes.AttributeContainerInternal
    n
    h
    • 3
    • 4
  • n

    natpryce

    02/18/2019, 3:55 PM
    Wow. Getting tests to run for a JS target in a multiplatform project is difficult: it’s not documented, and there are no examples in the kotlin-examples repo, and Gradle is opaque even with a Kotlin build script. Anyone got a small example of a multiplatform project that runs the tests for both the JVM and JS platforms?
    💯 2
    i
    g
    • 3
    • 63
  • d

    Dico

    02/19/2019, 2:31 AM
    Getting this error when I simply add a mingwX64 target without any configuration to my multiplatform project on version 1.3.21, gradle 4.7:
    kotlin.UninitializedPropertyAccessException: lateinit property compilation has not been initialized
    s
    • 2
    • 4
  • r

    ribesg

    02/19/2019, 9:17 AM
    fun cinterops(action: NamedDomainObjectContainer<DefaultCInteropSettings>.() -> Unit) = cinterops.action()
    fun cinterops(action: Action<NamedDomainObjectContainer<DefaultCInteropSettings>>) = action.execute(cinterops)
    These functions of
    KotlinNativeCompilation
    are identical and I can’t call any of them because both match anything I write, any idea?
    n
    • 2
    • 8
  • r

    ribesg

    02/19/2019, 9:53 AM
    Is there a built in way to convert a
    Throwable
    into a
    NSError
    or
    NSException
    ?
    n
    t
    +2
    • 5
    • 6
  • r

    ribesg

    02/19/2019, 3:41 PM
    How do I change the sourceSet of a target without losing IDE support?
    • 1
    • 2
  • d

    Dico

    02/19/2019, 5:02 PM
    Will we be able to use
    actual inline class
    to define
    expect class
    in the future? This to me seems like a prime use case of inline classes, as type aliases are not an option if there are tiny differences between the expected and actual type. I previously assumed that this is already possible, but it isn't, and I don't see a reason why it shouldn't be other than a bit of implementation complexity.
    👍🏼 1
    r
    • 2
    • 4
  • d

    dewildte

    02/19/2019, 10:32 PM
    Any ideas? ☝️
    d
    o
    • 3
    • 14
  • d

    dewildte

    02/20/2019, 1:19 AM
    This does not seem to work.
    private val httpClient: HttpClient = HttpClient {
            install(JsonFeature) {
                serializer = KotlinxSerializer().apply {
                    setMapper(GloUserDTO::class, GloUserDTO.serializer())
                }
            }
        }
    It produces:
    Error:(15, 57) Kotlin: [net.publicmethod.multi_glo_sdk.jvmMain] Unresolved reference: serializer
    s
    • 2
    • 7
  • n

    natpryce

    02/20/2019, 9:56 AM
    Are native Kotlin platforms supported in IntelliJ? When I try to debug failing tests on the native platform, IntelliJ runs them via Gradle and then debugs Gradle itself, not the native code it’s running. Do I need to install CLion to work on Kotlin Native at the moment?
    o
    • 2
    • 10
  • r

    ribesg

    02/20/2019, 9:59 AM
    What is the limit of what you can do with reflection in kotlin MPP? Can you do something simple like
    this::class.simpleName
    ? Is there a list of things part of
    stdlib
    ?
    s
    o
    • 3
    • 6
  • l

    louiscad

    02/20/2019, 12:06 PM
    Hi, I tried to add languageSettings to android sourceSets for an experimental annotation, unccessfully, following the example there: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#language-settings I tried the following:
    kotlin {
        sourceSets {
            filter { it.name.startsWith("android") }.forEach {
                it.languageSettings.apply {
                    useExperimentalAnnotation("kotlin.Experimental")
                }
            }
        }
    }
    but I'm getting an error because the test sourceSets defined by the Android Gradle plugin (version 3.3.1) don't have the experimental annotation. How can I solve that issue to enable this experimental annotation in my android source sets defined my Kotlin multiplatform gradle plugin? The exact error message is the following:
    Inconsistent settings for Kotlin source sets: 'androidDebugAndroidTest' depends on 'androidAndroidTest'
    'androidDebugAndroidTest': set of experimental annotations in use is []
    'androidAndroidTest': set of experimental annotations in use is [kotlin.Experimental]
    The dependent source set must use all experimental annotations that its dependency uses.
    h
    • 2
    • 6
  • p

    pardom

    02/20/2019, 4:52 PM
    Is there a multiplatform function to get the time?
    😞 2
    :no_red: 4
    l
    g
    s
    • 4
    • 6
  • p

    pardom

    02/20/2019, 5:00 PM
    And also an
    interval
    function that isn’t as terrible as this one I just wrote:
    Untitled.kt
    s
    • 2
    • 4
  • a

    altavir

    02/21/2019, 6:54 AM
    Does anyone have an example of working bintray deploy gradle configuration for an mpp project?
    g
    • 2
    • 2
  • h

    hmole

    02/21/2019, 7:37 AM
    @h0tk3y Hey, do you by any chance know if there is a way to do a
    includeBuild
    dependency substition on a preset of an mpp project? In a non-mpp android module I have a dependency
    mpp-module-android
    , and trying to substitute it with
    mpp-module
    , but it fails with
    Unable to find module with Gradle path
    h
    • 2
    • 9
  • n

    natpryce

    02/21/2019, 8:46 AM
    Is there document that outlines which language features are supported on different platforms? E.g. I’ve got a multiplatform project, and the tests are failing on native platforms for code that uses reified generics. Are they implemented on native? Will they be?
    g
    s
    • 3
    • 14
Powered by Linen
Title
n

natpryce

02/21/2019, 8:46 AM
Is there document that outlines which language features are supported on different platforms? E.g. I’ve got a multiplatform project, and the tests are failing on native platforms for code that uses reified generics. Are they implemented on native? Will they be?
g

gildor

02/21/2019, 8:51 AM
Reified generics should work. What kind error do you have?
n

natpryce

02/21/2019, 8:52 AM
I’m diagnosing the cause now. I’ve not been able to debug native code in a multiplatform project, so it’s slow to narrow down the cause.
Found it. The
is
operator doesn’t work with reified types in an object expression within the inline function. These tests fail on native:
@Test
    fun is_from_object() {
        inline fun <reified T> isA() = object {
            operator fun invoke(value: Any) = value is T
        }
        
        assertTrue(isA<String>()("a string"), "a string is a string")
        assertFalse(isA<String>()(10), "an int is not a string")
        
        assertTrue(isA<Int>()(10), "an int is an int")
        assertFalse(isA<Int>()("a string"), "a string is not an int")
    }
    
    @Test
    fun not_is_from_object() {
        inline fun <reified T> isNotA() = object {
            operator fun invoke(value: Any) = value !is T
        }
        
        assertFalse(isNotA<String>()("a string"), "a string is a string")
        assertTrue(isNotA<String>()(10), "an int is not a string")
        
        assertFalse(isNotA<Int>()(10), "an int is an int")
        assertTrue(isNotA<Int>()("a string"), "a string is not an int")
    }
Hmm... That code doesn’t even compile on the JVM platform (I get an error that inline functions are not supported in inline functions!).
I’ll make the tests also compile on the JVM and see if that makes a difference
Ok… I’ve reproduced the error in a small test. Reified types do not work when the inline function returns an object expression with methods that refer to the type parameter, and the inline function is defined in one compilation unit and called from another.
But do work when they are both in the same compilation unit
s

svyatoslav.scherbina

02/21/2019, 2:15 PM
This is known issue and will be fixed in 1.3.30.
n

natpryce

02/21/2019, 2:56 PM
👍
What’s the workaround?
s

svyatoslav.scherbina

02/21/2019, 4:22 PM
The workaround is to avoid using
inline
functions with reified parameters and object expressions declared in other compilation unit.
n

natpryce

02/21/2019, 5:00 PM
:-D
A workaround is to split the inline function with reified type into two parts, one which turns the reified type to a KClass, and the other which uses the KClass. It requires some unchecked cast warnings to be suppressed — only isInstance is defined on KClass, not safe downcast. But it does work.
👍 1
Thanks for your help.
View count: 4