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
android
  • e

    Eric Womer

    12/11/2022, 9:58 PM
    Anyone successfully cross-compile from windows/linux to iOS?
    j
    • 2
    • 1
  • r

    Rehan Sarwar

    12/12/2022, 8:53 AM
    Hi Guys, I have written the whole application in Clean architecture, and the UI is in jetpack compose. I have only written a test of the data, domain & presentation layer. For code coverage, I am using the KOVER. Can I ask the KOVER to ignore the UI layer written in Jetpack compose? #android
    s
    j
    • 3
    • 5
  • p

    Peter Mandeljc

    12/12/2022, 12:37 PM
    what's the difference between
    org.jetbrains.kotlin.android
    and
    kotlin-android
    ?
    j
    c
    • 3
    • 8
  • g

    Guilherme Delgado

    12/12/2022, 4:27 PM
    As a little challenge I’ve created a Desktop App (compose) to help me debug the UI State from my Android app. If you have the time, you can find more information here: https://github.com/GuilhE/JsonBroadcaster. 🙂
  • n

    Nebil

    12/12/2022, 5:10 PM
    Talkback announcing app_name on every screen and also adding "out of list" at the end of announcements on a dialog.
    c
    • 2
    • 5
  • d

    devhyeon0312

    12/13/2022, 3:15 AM
    LazyRow(
        modifier = modifier
            .pointerInput(Unit) {
                detectHorizontalDragGestures { change, dragAmount ->
                    coroutineScope.launch {
                        //Not Work : My Problem
                    }
                }
            }
    ) {
        ...
    }
    How can LazyRow detectHorizontalDragGestures?
    c
    • 2
    • 1
  • e

    Elio Maroun

    12/13/2022, 11:54 AM
    import kotlinx.datetime.toJavaLocalDate
    import kotlinx.datetime.toJavaLocalTime
    I am getting unresolved error when I remove these libraries from gradle although they are not related, I tried to invalidate cache and restart but still the same issue.
    implementation("com.github.thellmund.Android-Week-View:core:5.2.4")
    implementation("com.github.thellmund.Android-Week-View:jsr310:5.2.4")
    implementation("com.github.thellmund.Android-Week-View:emoji:5.2.4")
    implementation("com.himanshoe:kalendar-endlos:1.0.0")
    c
    • 2
    • 8
  • z

    zsperske

    12/13/2022, 6:13 PM
    I am trying to refer to an outer class like so
    this@MyOuterClass
    but I am getting a warning “This label is now resolved to ‘class MyOuterClass’ but soon it will be resolved to the closest ‘anonymous function’. Please consider introducing or changing explicit label name” What is the correct way to reference an outer class?
  • r

    roman.belov

    12/14/2022, 12:46 PM
    Hello, Android devs! Huge and exciting news specifically for you! KotlinDL, the Kotlin library for training and inferencing neural networks, is now available for Android and using it you can run practically any ONNX neural network on your device. There is also an Android Demo Application that shows how to use KotlinDL ONNX for Android. Learn more: https://blog.jetbrains.com/kotlin/2022/12/kotlindl-0-5-has-come-to-android/ We are eagerly keen on your feedback and feature requests! Join #kotlindl and #datascience to stay in touch!
    KotlinDL05.mp4
  • n

    Nebil

    12/14/2022, 1:59 PM
    Is it possible to use drawable as HeroPagerIndicator for the selected index?
    c
    • 2
    • 1
  • r

    Raman Sharma

    12/15/2022, 4:49 AM
    Hello Everyone, i am facing one issue. Java.lang.NoClassDefFounder: Failed resolution of: LKotlinx/serialization/json/JsonKt
  • r

    Raman Sharma

    12/15/2022, 4:49 AM
    This is happening when I am using jar of library. Whereas it is working for IOS
  • h

    hfhbd

    12/15/2022, 11:23 AM
    How do you use convention plugins to setup the sdk of a android application and android library? Ideally, I want to apply a base android plugin to get the
    android
    extension with the type of
    CommonExtension
    d
    g
    • 3
    • 6
  • r

    Rizwan

    12/16/2022, 5:38 AM
    Hello all, hope u all are good, I have a html file where I want to upload my image in Img tag from webview in android, how can we do it, image is in internal storage
  • a

    Ahmed Sellami

    12/16/2022, 10:14 AM
    How can I get a list of a?
    data class Item(val a: Int, val b: Int)
    
    val items = listOf(Item(1,2), Item(3,4))
    
    val aList = // [1,3]
    j
    • 2
    • 8
  • o

    Omkar Amberkar

    12/16/2022, 6:10 PM
    How do i save state of motionlayout on orientation change in compose? When transitioning to start to end and changing orientaiton, i want the end orientation to be shown after orientation change, but it defaults back to start. Checking logs i see that the motion layout state current progress was reset to 0.0 (start state) instead of 1.0 (end state)
  • c

    CLOVIS

    12/16/2022, 9:46 PM
    Are
    sealed class
    really not supported yet on Android?
    {
      "kind": "error",
      "text": "com.android.tools.r8.internal.Jc: Sealed classes are not supported as program classes",
      "sources": [
        {
          "file": "[PATH REDACTED]/NavigationMenu.class"
        }
      ],
      "tool": "D8"
    }
    m
    j
    +3
    • 6
    • 11
  • s

    Sarav Ramaswamy

    12/17/2022, 7:32 AM
    Hello, I have an interface Lib2 in library module L2 that extends interface Lib1 from another library module L1. If I use Lib2 from my app class, I get this error when I compile the app. (No visibility keywords such as private are used.)
    error: supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
      class com.test.lib2.Lib2, unresolved supertypes: com.test.lib1.Lib1
    If the App class is written in Java, I do not see the error. Any idea why the package boundary/visibility is an issue only for Kotlin and not for Java? I can use
    api
    to get around this but my question is why Kotlin behaves diffierent?
  • c

    CLOVIS

    12/17/2022, 9:52 AM
    I get
    Cannot invoke "com.android.tools.idea.gradle.project.sync.GradleSyncListener.syncFailed(com.intellij.openapi.project.Project, String)" because "syncListener" is null
    when syncing with AS
    t
    a
    • 3
    • 2
  • s

    Siddharth Sharma

    12/17/2022, 4:13 PM
    https://github.com/Kotlin/kotlinx.coroutines/issues/3555#issuecomment-1356315434 hi can anybody answer this question here?
    k
    • 2
    • 6
  • e

    Eric Womer

    12/17/2022, 7:49 PM
    Is there a way to get the name of a variable and print it out to Text() ?
  • r

    Rizwan

    12/18/2022, 3:20 PM
    I don't know why are people reacting 'not koltin' in android channel
    e
    c
    e
    • 4
    • 6
  • l

    lpirro

    12/18/2022, 6:19 PM
    I’m trying to use HILT to inject an implementation of a repository class into the UseCase class (the interface lives in the
    domain
    module, and the implementation in the
    repository
    module with the
    repository
    module depending on the
    domain
    one) but receiving an error when building the app: DomainModule.kt - lives into
    :domain
    module
    @Module
    @InstallIn(SingletonComponent::class)
     object DomainModule {
    
        @Provides
        fun provideGetUpcomingLaunchesUseCase(repository: SpaceHubRepository): GetUpcomingLaunchesUseCase {
            return GetUpcomingLaunchesUseCaseImpl(repository)
        }
    
    }
    SpaceHubRepository.kt - lives into:
    :domain
    module
    interface SpaceHubRepository {
        suspend fun getUpcomingLaunches(): Flow<List<Launch>>
    }
    RepositoryModule.kt - lives into
    :repository
    module
    @Module
    @InstallIn(SingletonComponent::class)
    object RepositoryModule {
    
        @Provides
        fun provideRepository(
            apiService: SpaceHubApiService,
            launchMapper: LaunchMapper
        ): SpaceHubRepository {
            return SpaceHubRepositoryImpl(apiService, launchMapper)
        }
    
        @Provides
        fun provideLaunchMapper(): LaunchMapper = LaunchMapperImpl()
    }
    c
    y
    • 3
    • 6
  • s

    SUBRATA SHARMA

    12/19/2022, 12:46 PM
    https://twitter.com/sharmasubrata45/status/1604804891377270786?t=3ZD74rL1Yn27unEDmtjb_w&amp;s=31
  • d

    Daniel Okanin

    12/19/2022, 7:53 PM
    Hi everyone! Any reason why I don’t see any warning/quick fix of custom lint?
    c
    • 2
    • 1
  • g

    Gal Kohen

    12/20/2022, 8:41 AM
    Hey, everyone, who knows if updating an app will take out the app from the restricted bucket?
  • p

    Pedro Alberto

    12/20/2022, 4:33 PM
    Do you guys know a way to somehow log all events from a flows in a app ? We would like to debug the all flows and log the data but I haven't found a mechanism.
    k
    • 2
    • 3
  • s

    Slackbot

    12/20/2022, 7:49 PM
    This message was deleted.
    c
    • 2
    • 1
  • e

    Elio Maroun

    12/21/2022, 7:53 AM
    https://stackoverflow.com/questions/74865176/how-to-add-drag-to-custom-layout-and-change-the-color-of-the-dragged-surface-in
  • s

    Sergio C.

    12/21/2022, 10:34 AM
    Hi, how could we make this function work like a delegate property?
    fun TextView.drawableStart(drawableRes: Int) {
        val drawable = ContextCompat.getDrawable(context, drawableRes)
        drawable?.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight)
        setCompoundDrawables(drawable, null, null, null)
    }
    I want to do something like:
    someTextview.drawableStart = R.drawable.someDrawable
    g
    • 2
    • 27
Powered by Linen
Title
s

Sergio C.

12/21/2022, 10:34 AM
Hi, how could we make this function work like a delegate property?
fun TextView.drawableStart(drawableRes: Int) {
    val drawable = ContextCompat.getDrawable(context, drawableRes)
    drawable?.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight)
    setCompoundDrawables(drawable, null, null, null)
}
I want to do something like:
someTextview.drawableStart = R.drawable.someDrawable
g

gildor

12/21/2022, 10:37 AM
do you mean: var TextView.someDrawable: Int set(drawableRes: Int) { … }
I just don’t see any delegation here, just standard extension property
s

Sergio C.

12/21/2022, 10:38 AM
cool that's what I was looking for!
var TextView.drawableStart: Int
    set(drawableRes: Int)  {
        val drawable = ContextCompat.getDrawable(context, drawableRes)
        drawable?.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight)
        setCompoundDrawables(drawable, null, null, null)
    }
    get() {
        throw Error("Drawable Start Not available")
    }
It works but It must be a var and have a getter to work
g

gildor

12/21/2022, 11:01 AM
Correct, it was a typo in my example, it cannot be val of course, if you need setter
You need getter with Int, you can do this: var drawableStart: Int = -1 set(value) { field = value }
Not perfect, because it will have getter value only after first set, but imo better than exception
s

Sergio C.

12/21/2022, 11:04 AM
Initializer is not allowed here because this property has no backing field
g

gildor

12/21/2022, 11:04 AM
Still, function looks a bit more semantically correct for this case
s

Sergio C.

12/21/2022, 11:04 AM
It doesn't work here
It doesn't let me have an initializer
probably because it's an extension on TextView
g

gildor

12/21/2022, 11:05 AM
Should work
s

Sergio C.

12/21/2022, 11:06 AM
no, try it
g

gildor

12/21/2022, 11:06 AM
On phone
https://kotlinlang.org/docs/properties.html#backing-fields
s

Sergio C.

12/21/2022, 11:07 AM
it's ok as is
thanks for the help
g

gildor

12/21/2022, 11:07 AM
Ahhhh
Sorry, you right, of course, it's extension
You can implement it by saving value to TV tags if want to make getter work
So no backing field, but getter will read from tags
Again, more like a workaround, it's not perfect because cannot get value before first initialization (same with backing field)
s

Sergio C.

12/21/2022, 11:14 AM
using tags for the getter is an idea... but for now I just need the setter, just to make reading the code easier.
*getter
g

gildor

12/21/2022, 11:16 AM
If you have a setter, you need a getter for property, this how properties work in Kotlin Personally I would just use extension function for this case, because it's impossible to implement getter correctly, just to avoid possible confusion
s

Sergio C.

12/21/2022, 11:18 AM
yes you are correct
View count: 95