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

    jw

    08/05/2022, 7:21 PM
    no. at this time it's enough of a hassle tracking Kotlin compatibility. I would suggest evangelizing that JetBrains decouple their releases of the compiler+runtime from their releases of their Compose UI fork so that we can get access to stable, multiplatform versions at a similar pace to Google's release.
    j
    l
    • 3
    • 3
  • w

    wiktor

    08/16/2022, 5:20 AM
    hey 👋 I just wanted to ask: is it possible to use molecule in a KMM ? I would like to place the logic in a shared module and subscribe to StateFlow from android/ios targets
    k
    • 2
    • 4
  • j

    jean

    08/16/2022, 6:19 AM
    The kotlinpoet channel is archived so I assumed one should use this channel to ask a questions? I’m trying to implement a
    fun interface
    but the generated code is using a`:` instead of a
    =
    like so :
    public fun <AsyncDataType, LoadEvent> loadAsyncData(
        key: TransitionKey,
        loader: (LoadEvent) -> AsyncDataType
    ): ReusableTransition<LoadEvent> { updater, event ->
        ...
    }
    I use the following code to generate it
    FunSpec.builder("loadAsyncData")
        .addTypeVariable(asyncDataType)
        .addTypeVariable(loadEvent)
        .addParameter("key", TransitionKeyGenerator.className)
        .addParameter("loader", loader)
        .returns(reusableTransition)
        .addCode(
            CodeBlock.builder()
                .add(...)
                .build()
        ).build()
    g
    • 2
    • 1
  • i

    itnoles

    08/16/2022, 11:36 PM
    is this is known issues about mockwebserver for java.lang.NoClassDefFoundError: okhttp3/internal/Util?
  • j

    jw

    08/16/2022, 11:51 PM
    Your version doesn't match the OkHttp version
  • i

    itnoles

    08/16/2022, 11:53 PM
    oh okay, then fix dependenices
  • j

    Jemo

    08/17/2022, 9:41 AM
    Help needed: SQLDelight select query with when clause where argument is list of strings not returns any records https://stackoverflow.com/questions/73385457/sqldelight-select-query-with-when-clause-where-argument-is-list-of-strings
  • j

    Javier

    08/18/2022, 12:42 PM
    Is it possible to test a view which contains a recyclerview with paparazzi?
    s
    • 2
    • 5
  • c

    Colton Idle

    08/20/2022, 7:55 AM
    I'm crashing due to a header that comes back in a response
    java.lang.IllegalArgumentException: Unexpected char 0x41c at 74 in Content-Disposition value:  inline; filename="7326f70a-1b88-4ff8-afc8-5f52190c7052b7179b07fcb968827a_Мала.jpg"
    I wrote this interceptor and I set it as a network interceptor, but I still get the same crash (as if the interceptor doesn't even get applied). Can anyone point me in the right direction?
    private val REMOVE_HEADER_INTERCEPTOR = Interceptor { chain ->
      val originalResponse = chain.proceed(chain.request())
      originalResponse.newBuilder()
        .removeHeader("Content-Disposition")
        .build()
    }
    e
    j
    • 3
    • 12
  • r

    ribesg

    08/22/2022, 3:48 PM
    Why is there no mention of iOS/Apple on this page? Or any okio page it seems https://square.github.io/okio/file_system/#multiplatform
    j
    j
    • 3
    • 4
  • w

    William Reed

    08/22/2022, 8:06 PM
    is there a standard way to undo a migration (downgrade version) with sqldelight? or would you have to increment the version and write another migration to restore the old table state
  • j

    jw

    08/22/2022, 8:16 PM
    You would need to write a migration
  • p

    Piotr Prus

    08/22/2022, 9:33 PM
    I have an issue with
    sqldelight
    and release version of android app. I have the file favourites.sq and
    CREATE TABLE
    statement into it. On debug version of the app it works, but on release it is not creating the table and app crash with error:
    no such table: favourite
    . I found somewhere on slack that I can put
    CREATE TABLE
    also in 1.sqm. I did that and surprisingly it works. Unfortunatelly, on debug version I go t the error now:
    table favourite already exists
    How can I get rid of it and why the release version of the app needs the migration file if I actually do not migrate anything ? 😕
    • 1
    • 1
  • l

    Lukasz Kalnik

    08/23/2022, 1:56 PM
    What is the best practice to refresh OAuth access tokens using a refresh token in OkHttp? I have the following setup, but it's failing in case of parallel calls. The
    synchronized(lock)
    doesn't seem to prevent the second call to try to refresh the token as well.
    val okHttpClient = OkHttpClient.Builder()
        .addInterceptor(AccessTokenInterceptor(oAuthRepository))
        .authenticator(RefreshTokenAuthenticator(oAuthRepository))
        .build()
    
    val lock = Any()
    
    private class AccessTokenInterceptor(
        private val oAuthRepository: OAuthRepository
    ) : Interceptor {
    
        override fun intercept(chain: Chain): Response {
            synchronized(lock) {
                val token = oAuthRepository.accessToken
    
                val request = chain.request().newBuilder().apply {
                    if (token != null) header("Authorization", "Bearer $token")
                }.build()
                return chain.proceed(request)
            }
        }
    }
    
    private class RefreshTokenAuthenticator(
        private val oAuthRepository: OAuthRepository
    ) : Authenticator {
    
        override fun authenticate(route: Route?, response: Response): Request? {
            if (response.responseCount >= 2) return null
    
            synchronized(lock) {
                return runBlocking {
                    oAuthRepository.refreshTokens().map {
                        oAuthRepository.accessToken
                    }
                }.fold(
                    ifLeft = { null },
                    ifRight = {
                        it?.let { token ->
                            response.request.newBuilder()
                                .header("Authorization", "Bearer $token")
                                .build()
                        }
                    }
                )
            }
        }
    }
    y
    j
    c
    • 4
    • 8
  • w

    William Reed

    08/24/2022, 3:45 PM
    I have this config for sqldelight
    sqldelight {
        database("MyDb") {
            packageName = "com.foo.bar"
            dialect = "mysql"
    
            sourceFolders = listOf("sqldelight")
            migrationOutputDirectory = file("$buildDir/resources/main/migrations")
            migrationOutputFileFormat = ".sql"
        }
    }
    the
    generateMainDatabaseMigrations
    task is not being created. is there something else I’m missing? I have my initial
    CREATE TABLE
    statement & queries in
    src/main/sqldelight/com/foo/bar/…
    and I have my
    .sqm
    file in
    src/main/sqldelight/…
    h
    • 2
    • 2
  • k

    KamilH

    08/24/2022, 8:22 PM
    In SQLDelight, I have a
    moduleA
    that contains a table definitions. I would like to write some queries for those tables in a separate
    moduleB
    . Is it possible? I had found
    dependency(project(":path"))
    option and I tried to use it, however when I try to reference a table in a
    .sq
    file it fails to resolve it. Is there anything I’m missing?
    h
    • 2
    • 7
  • m

    Michal Klimczak

    08/26/2022, 6:00 AM
    hey, there are some little fixes in kotlinpoet that I'm waiting for. not trying to push or anything, but maybe someone knows if 1.13 release is planned anytime soon?
    p
    h
    z
    • 4
    • 5
  • a

    Asad Mukhtar

    08/30/2022, 5:28 AM
    Hi Guys, How i know the api call contains file uploading or simple api call using retrofit?
  • c

    Colton Idle

    08/30/2022, 7:56 AM
    I'm using googles/androids modern storage library for choosing a photo. Now I need to upload via okhttp as a PUT request with Binary Data. I created my own InputStreamRequestBody and my solution loosely based off of this post, but my upload seems to fail because my server doesn't like the
    Transfer-Encoding: chunked
    header. If I replay that request, omitting that header via charles, then the upload succeeds. If I try to remove the header programatically, it still appears in the request (according to charles). Any idea whats up with that? Am I taking the wrong path here?
    val resolver = getApplication<Application>().contentResolver
    val doc = DocumentFile.fromSingleUri(getApplication(), content)!!
    val type = (doc.type ?: DEFAULT_TYPE).toMediaType()
    val contentPart = InputStreamRequestBody(type, resolver, content)
    
    val request = Request.Builder().url(url).addHeader("DOES", "THIS WORK").put(contentPart).removeHeader("Transfer-Encoding").build()
    y
    e
    • 3
    • 8
  • g

    grahamborland

    08/31/2022, 12:57 PM
    Using SQLDelight, how does a query listener know when the database has changed? Does it just know the data must have changed when it runs an
    INSERT
    or
    UPDATE
    , or does it do something lower-level like watching the filesystem for changes to the database?
  • j

    jw

    08/31/2022, 1:01 PM
    The first one. It sends notifications at the library level after mutator queries complete their transactions. It does not use -level triggers or anything.
    l
    k
    d
    • 4
    • 5
  • b

    Benoit Quenaudon

    08/31/2022, 6:14 PM
    Is Glide a square library?
    s
    • 2
    • 1
  • j

    John Aoussou

    09/04/2022, 5:05 AM
    Hello, I'm trying to create an SQLDelight DB in a Compose Multiplatform (Android + Desktop) project. My outermost
    build.gradle.kts
    file looks like this
    group "com.example"
    version "1.0-SNAPSHOT"
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
        }
    }
    
    plugins {
        kotlin("multiplatform") apply false
        kotlin("android") apply false
        id("com.android.application") apply false
        id("com.android.library") apply false
        id("org.jetbrains.compose") apply false
    }
    I'm trying to follow the info here https://cashapp.github.io/sqldelight/multiplatform_sqlite/ but I'm unable to make the parallel. Where am I supposed to insert
    'com.squareup.sqldelight:gradle-plugin:1.5.3'
    and
    'com.squareup.sqldelight'
    ?
  • h

    hfhbd

    09/04/2022, 12:10 PM
    You are already using the plugin block, so just add the gradle plugin in the outermost build.gradle.kts:
    group "com.example"
    version "1.0-SNAPSHOT"
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
        }
    }
    
    plugins {
        kotlin("multiplatform") apply false
        kotlin("android") apply false
        id("com.android.application") apply false
        id("com.android.library") apply false
        id("org.jetbrains.compose") apply false
        id("com.squareup.sqldelight) version "1.5.3" apply false // or define the version in other places like the kotlin version
    }
    And apply the plugin in the sub project, eg app:
    plugins {
        kotlin("multiplatform")
        kotlin("android")
        id("com.android.application")
        id("com.android.library")
        id("org.jetbrains.compose")
        id("com.squareup.sqldelight)
    }
  • p

    Philip Dukhov

    09/06/2022, 9:22 AM
    Hi, I'm using moshi+retrofit and trying to sort out proguard setup I have a class:
    data class PingResponse(
        @Json(name = "needs_update") val shouldUpdate: Boolean,
    )
    And it works fine in debug, but with release minification it crashes with the following:
    IllegalArgumentException: No property for required constructor parameter #0 shouldUpdate of fun `<init>`(kotlin.Boolean): not.minimized.package.PingResponse
    It works fine if I apply
    @JsonClass(generateAdapter = true)
    to class. As per documentation it sounds like I only need to apply
    @JsonClass(generateAdapter = false)
    to enums, and the rest should work out of the box. I find it very tricky that it works in debug without this annotation but fails in release. This comment suggests not minimizing all the models, but I don't find it much useful in my case, as I don't store all the models in one package. I can apply
    @JsonClass(generateAdapter = true)
    to all my models, the biggest issue is that if I forget to do that I won't know there's a problem until I run release version. Am I missing some other way to set it up, or is there a way to make app crash in debug(or build time check?), same as it does in release, in case when model has no
    JsonClass
    annotation?
    z
    e
    • 3
    • 5
  • h

    hfhbd

    09/07/2022, 4:29 AM
    Kotlinpoet: How do you MemberName with string templates? I want to use a member of an object:
    println("Hello ${Foo.bar}")
    but I get
    println("Hello $Foo.bar")
    which is wrong.
    p
    e
    • 3
    • 19
  • i

    Ivan Đorđević

    09/07/2022, 7:58 AM
    SQLDelight: Would it be possible for
    Query<...>.asFlow().mapToList()
    to be cached somehow when the related tables haven't changed? Right now this uses a cold flow and reads from the DB on each collect. Is something like this on the roadmap currently?
    k
    j
    • 3
    • 3
  • x

    xxfast

    09/09/2022, 5:29 AM
    Okio: Is there a way to get access to app private files directory on android with
    FileSystem
    ? Always get
    Caused by: android.system.ErrnoException: open failed: EROFS (Read-only file system)
    when I do this on
    androidMain
    FileSystem.SYSTEM.sink("test.json".toPath)
    s
    y
    • 3
    • 6
  • x

    xxfast

    09/13/2022, 11:41 AM
    Okio:
    Json.decodeFromBufferedSource()
    does this halt whatever thread you call it from?
  • j

    jw

    09/13/2022, 11:47 AM
    Halt?
Powered by Linen
Title
j

jw

09/13/2022, 11:47 AM
Halt?
View count: 22