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
compose-desktop
  • s

    spierce7

    07/30/2021, 2:33 PM
    I’m seeing errors when notarizing an application with files from compose. How would I work around that?
    {
    severity: "error",
    code: null,
    path: "My_App-1.0.0.dmg/My <http://App.app/Contents/app/sqlite-jdbc-3.34.1-371b212b7663f42133e45d49e82ad30.jar/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib|App.app/Contents/app/sqlite-jdbc-3.34.1-371b212b7663f42133e45d49e82ad30.jar/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib>",
    message: "The binary is not signed.",
    docUrl: null,
    architecture: "x86_64"
    },
    {
    severity: "error",
    code: null,
    path: "My_App-1.0.0.dmg/My <http://App.app/Contents/app/sqlite-jdbc-3.34.1-371b212b7663f42133e45d49e82ad30.jar/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib|App.app/Contents/app/sqlite-jdbc-3.34.1-371b212b7663f42133e45d49e82ad30.jar/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib>",
    message: "The signature does not include a secure timestamp.",
    docUrl: null,
    architecture: "x86_64"
    }
    m
    a
    • 3
    • 15
  • r

    rsktash

    07/31/2021, 8:44 AM
    Hi I’m having an issue with expect/actual composable function when built from scratch app works without exception but when make any change to my app and rerun sometimes throwing error
    java.lang.NoSuchMethodError: No static method Blablabla
    j
    • 2
    • 16
  • s

    Sivan

    07/31/2021, 5:10 PM
    Upgrading to 
    v1.0.0-alpha1-rc1
     throws the following error :
    Could not find androidx.annotation:annotation:1.2.0.
    
    Required by:
                project : > org.jetbrains.compose.ui:ui-tooling:1.0.0-alpha1-rc1 > org.jetbrains.compose.ui:ui-tooling-desktop:1.0.0-alpha1-rc1 > org.jetbrains.compose.ui:ui-tooling-preview:1.0.0-alpha1-rc1 > org.jetbrains.compose.ui:ui-tooling-preview-desktop:1.0.0-alpha1-rc1
    Am I missing something?
    i
    • 2
    • 2
  • a

    Alexander Suraphel

    07/31/2021, 5:36 PM
    i cloned
    JetBrains/compose-jb
    and did
    desktop:package
    . The size of resulting .app file is 104.5MB. I’m on macOS 11.5.1. Why is the application large for such a simple example project?
    b
    m
    c
    • 4
    • 8
  • a

    atsushieno

    08/01/2021, 6:22 AM
    What would make it possible to debug Compose for Desktop apps on IDEA?
    c
    o
    • 3
    • 4
  • r

    rsktash

    08/01/2021, 10:24 AM
    I’m fed up with this issue When I make any change to Coomposable function bodies which call this Composable and run to android my device AS doing something wrong and at runtime throwing this error
    o
    i
    +2
    • 5
    • 18
  • v

    Victor Yakovlev

    08/01/2021, 1:03 PM
    after migration to 1.0.0-alpha1-rc1 a strange bug appeared First screenshot - 0.5.0-build270 Second screenshot - 1.0.0-alpha1-rc1
    o
    r
    • 3
    • 7
  • a

    Alexander Suraphel

    08/01/2021, 6:29 PM
    We are choosing between Electron and Compose Desktop. What thing I feel will be missing is powerful charting libs. Web has powerful libraries like D3 and other derived from it. Are are great options for compose in that area?
    c
    r
    +5
    • 8
    • 17
  • s

    Steve

    08/01/2021, 7:06 PM
    Is there a layout that my three elements use the full width but the left and right have the width with content wraped and the mid will fill the space left in the middle?
    t
    • 2
    • 2
  • s

    spierce7

    08/02/2021, 4:50 AM
    @Nik I tried the approach you suggested of copying resources out of the jar into a folder so that they can be accessed outside of the jar. This works when the app is in the build folder, but when it’s in the
    /Applications
    folder, it has an issue when trying to copy to the
    My <http://App.app/Contents/resources|App.app/Contents/resources>
    dir.
    java.nio.file.FileSystemException: /resources: Read-only file system
    Does anyone have a recommendation of where I should be saving these resource files?
    o
    a
    • 3
    • 5
  • a

    atsushieno

    08/02/2021, 9:31 AM
    e: /home/atsushi/.gradle/caches/jars-8/e51b24e2bc2b3d6212beb0e53efc315d/compose-gradle-plugin-1.0.0-alpha1-rc1.jar!/org/jetbrains/compose/desktop/DesktopExtension.class: Class 'org/jetbrains/compose/desktop/DesktopExtension' was compiled with an incompatible version of Kotlin. The binary version of its bytecode is unknown, expected version is 1.0.3
    Which kotlin version makes it work with compose-gradle-plugin:1.0.0-alpha1-rc1 ? I got this error with kotlin-gradle-plugin:1.5.30-M1 which I assume is the latest.
    ✅ 1
    a
    j
    • 3
    • 8
  • g

    Guldana Kystaubayeva

    08/02/2021, 12:17 PM
    There is some bug with VerticalScrollbar in AlertDialog. Buttons overlap it at the bottom. And Text at the top is also moving, when it shouldn't.
    18-07-46_Trim.mp4
    i
    a
    +2
    • 5
    • 7
  • m

    Michal Harakal

    08/02/2021, 1:51 PM
    I would like to take a screenshot in desktop app as a part of jvmTest. In androidTest I can do that with takeScreenshot method from uiautomator.UiDevice. Any hint how I can do that without spinning up an Android emulator (I have both targets …)?
    b
    i
    • 3
    • 4
  • r

    rsktash

    08/02/2021, 8:46 PM
    hi when there will be binary compatibility with jetpack compose? There are some libraries like coil, lottie which we can use in android module
    k
    • 2
    • 3
  • s

    Steve

    08/02/2021, 10:48 PM
    I would like to have a scrollable element for horizontal scoll. I tried the following two code as example and both didn't work. Is there another way to get the scrollable element?
    fun main() = Window {
        val stateVertical = rememberScrollState(0F)
        Row(modifier = Modifier.width(400.dp)
            .horizontalScroll(stateVertical)) {
            listOf(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17).forEach{
                val text = "Hello, Desktop! $it"
                Button(onClick = {
                }) {
                    Text(text)
                }
            }
        }
    }
    fun main() = Window {
        ScrollableRow (modifier = Modifier.width(400.dp)){
            listOf(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17).forEach{
                val text = "Hello, Desktop! $it"
                Button(onClick = {
                }) {
                    Text(text)
                }
            }
        }
    }
    a
    k
    • 3
    • 3
  • r

    rsktash

    08/03/2021, 4:00 AM
    Hi how can we call fast*** util. functions in common module?
    c
    • 2
    • 1
  • s

    Sam Michael

    08/03/2021, 8:28 AM
    Trying to make a go game board. Wonder if anyone here attempted this in compose? I seem to be stuck with the idea of manually drawing the board lines (using canvas API) and then overlaying circular buttons on top. It seems like chess would be easier because each button could represent a board square, whereas in go we play stones on the corner. Anyway, anyone interested or have any suggestions?
    d
    • 2
    • 5
  • j

    Joey Heck

    08/03/2021, 8:42 PM
    calling a java FileDialog works great, unless I'm in a TextField.
    val fileDialog = FileDialog(window.window)
    fileDialog.isVisible = true
    triggers
    Exception in thread "AWT-EventQueue-0" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for CancellableContinuation(DispatchedContinuation[FlushCoroutineDispatcher@8e8a808, Continuation at androidx.compose.foundation.gestures.TapGestureDetectorKt.awaitChannelUpOrCancel(TapGestureDetector.kt:275)@45a19ee9]){Completed}@50fcdf16. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
    o
    i
    • 3
    • 9
  • s

    SrSouza

    08/03/2021, 10:40 PM
    Hi folks, Compose-desktop has any version that is compiled on top of Compose Android 1.0.0 ? (specially the compiler plugin)
    i
    • 2
    • 1
  • a

    Alexey Glushkov

    08/04/2021, 11:56 AM
    Hi everybody. I’ve managed to run compose-jb todo example but I see that it uses
    buildSrc
    instead of gradle
    includeBuild
    . In my pet project I use
    includeBuild
    and I didn’t manage to setup compose-jb with it. I’ve reproduced the error I get in my pet project with the todo example. There’re my changes: https://github.com/soniccat/compose-jb/commit/cf2dc97e8a42bc1fbd3aa678799537bd5f447921 The full error message is here https://pastebin.com/ghZLKS21 Probably I’ve messed up with gradle… would be great to hear any ideas.
    k
    • 2
    • 2
  • a

    Alexander Kurasov[JB]

    08/04/2021, 2:01 PM
    We are happy to announce that Compose Multiplatform went Alpha today. The build
    1.0.0-alpha2
    is already available in the Maven repo.  While its API is not completely stabilized, we will strive to minimize API changes in future, focusing on stabilizing the framework on its way to beta and 1.0.  We believe that though the current version may have certain issues, it already could be used for early prototyping and PoC preparations of real applications built on Compose Multiplatform technology.  And as usual - feel free to share feedback about Compose Multiplatform, so that we could improve it. Enjoy composing! P.S. Some details about the Release could be found here - https://blog.jetbrains.com/kotlin/2021/08/compose-multiplatform-goes-alpha/
    :party-parrot: 10
    🎉 38
    :kotlin-intensifies: 6
    s
    i
    +5
    • 8
    • 15
  • a

    Alexander Suraphel

    08/04/2021, 5:45 PM
    Has anyone managed to render a Preview ? I just tried it with:
    ✅ 1
    s
    • 2
    • 8
  • t

    Tristan B.

    08/04/2021, 6:17 PM
    I have updated compose desktop from 1.0.0-alpha1-rc4 to 1.0.0-alpha1 and I can't build an executable anymore. When I execute "runDistributable", I have the following error : "Error: Could not find or load main class esources"
    ➕ 1
    a
    m
    • 3
    • 10
  • d

    Dario Valdespino

    08/04/2021, 7:19 PM
    The latest JetBrains Toolbox release is now fully made in Compose Desktop (which is awesome). Now, I noticed that the popup window when you click on the tray icon looks very nice and native. How did they manage that? I've tried a lot of things (like undecorated windows with transparent backgrounds), but have achieved nothing. Any thoughts on this?
    d
    c
    • 3
    • 5
  • d

    Dominaezzz

    08/04/2021, 8:56 PM
    Which version of Kotlin can I use for the alpha version?
    1.5.10
    ,
    1.5.20
    and
    1.5.21
    don't seem to work.
    ✅ 1
    a
    • 2
    • 2
  • s

    Sam Michael

    08/04/2021, 9:56 PM
    Have a question still about drawBehind, how can I get the same result but draw on top of some content? It seems like when I use Canvas by itself it puts it after the text, but I don't want it to be behind either. I just want directly over the cross but on top
    Box {
        Text(
            modifier = if (isVisible.value) Modifier.drawBehind {
                drawCircle(Color.Black, radius = 10f)
            } else Modifier,
            text = text.value,
            color = Color.Gray,
            fontSize = 30.sp
        )
    }
    androidx.compose.foundation.Canvas(modifier = Modifier.fillMaxSize(), onDraw = {drawCircle(color = Color.Black, radius = 10f)})
    d
    • 2
    • 2
  • r

    rsktash

    08/05/2021, 2:10 PM
    I’m having this error after upgrading to the last version
    j
    • 2
    • 4
  • j

    Joey Heck

    08/05/2021, 3:48 PM
    This morning, on a fresh project with 1.0.0-alpha1, I'm getting:
    Could not find androidx.annotation:annotation:1.2.0
    i
    • 2
    • 5
  • s

    Sam Michael

    08/05/2021, 8:34 PM
    Still having trouble with getting Compose Preview annotation to resolve. Added the uiTooling implementation and compose-gradle-plugin:1.0.0-alpha1-rc1, all the stuff I found in the threads above.
    ✅ 1
    a
    • 2
    • 4
  • s

    spierce7

    08/05/2021, 10:35 PM
    I’m trying to make my Compose application self-updating. I’ve never messed with `ClassLoader`s before, but thought it might be possible to do with them.
    val jarFile = File("<Path to downloaded jar>")
    val classLoader = URLClassLoader(
        arrayOf(jarFile.toURI().toURL()),
        Thread.currentThread().contextClassLoader
    )
    
    val myMainClass = Class.forName("MyClass", true, classLoader)
    val mainMethod = myMainClass.getDeclaredMethod("main")
    mainMethod.invoke(null)
    This works until the AWT loop starts and my class loader hasn’t been set on that thread so it can’t find the right class. I’m sure there is a better way to do this. Can anyone point me in the right direction?
    j
    c
    • 3
    • 5
Powered by Linen
Title
s

spierce7

08/05/2021, 10:35 PM
I’m trying to make my Compose application self-updating. I’ve never messed with `ClassLoader`s before, but thought it might be possible to do with them.
val jarFile = File("<Path to downloaded jar>")
val classLoader = URLClassLoader(
    arrayOf(jarFile.toURI().toURL()),
    Thread.currentThread().contextClassLoader
)

val myMainClass = Class.forName("MyClass", true, classLoader)
val mainMethod = myMainClass.getDeclaredMethod("main")
mainMethod.invoke(null)
This works until the AWT loop starts and my class loader hasn’t been set on that thread so it can’t find the right class. I’m sure there is a better way to do this. Can anyone point me in the right direction?
Thread.currentThread().contextClassLoader = classLoader
Thread.getAllStackTraces().forEach { (t, _) ->
    if (t.contextClassLoader != null) {
        t.contextClassLoader = classLoader
    }
}
Seems to work, but I imagine new threads that spawn won’t have the class loader. There has to be a better way to do this.
j

jim

08/06/2021, 5:22 AM
ClassLoaders are tricky.  Setting the 
contextClassLoader
 feels very sketchy to me; you shouldn't need to set the 
contextClassLoader
. I'm not sure I understood the issue with the AWT loop.  AWT is always going to get loaded using the parent classloader because it is part of the 
java.
 namespace which is special cased (for security reasons?).  But this shouldn't matter, as long as all your classes are loaded using your custom ClassLoader.  Any class referenced by 
MyClass
 and which is only provided by 
jarFile
 should be loaded by your classloader. If you can elaborate on specifically what problem you were facing with your old approach, perhaps we can help.  Although it is worth noting that we are venturing into purely java territory, and there is nothing compose-specific about these questions, so you might get more visibility in a place like StackOverflow.
c

Casey Brooks

08/09/2021, 12:21 AM
There’s a library specifically for this, update4j. I haven’t used it myself but it seems pretty solid, and will probably give you a much better result than trying to do it all yourself. As Jim said, classloaders are tricky and there’s a thousand ways you could get it wrong which would lead to subtle “heisenbugs”, so it’s better to leave it up to the folks who actually understand this stuff 😅 https://github.com/update4j/update4j
s

spierce7

08/09/2021, 3:21 AM
@jim Just saw your responses. Thanks for taking the time.
Setting the 
contextClassLoader
 feels very sketchy to me; you shouldn’t need to set the 
contextClassLoader
This all feels super sketchy to me lol
Any class referenced by 
MyClass
 and which is only provided by 
jarFile
 should be loaded by your classloader.
I actually didn’t see that happening. Based on what I was seeing, I made the assumption that the classloader on the thread that’s running the code is what is used to load the new class.
Thread.currentThread().contextClassLoader = classLoader
Thread.getAllStackTraces().forEach { (t, _) ->
    if (t.contextClassLoader != null) {
        t.contextClassLoader = classLoader
    }
}
Actually did get my jar running. I read a blog post about how resolving all memory leaks with an approach like this is almost completely impossible though. I think taking this approach for an auto-updating app seems bad.
@Casey Brooks Thanks - I’ll give update4j a shot
View count: 1