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

    Ali

    01/28/2022, 5:14 PM
    Anyone has any idea why this crash
    Caused by android.os.BadParcelableException: Parcelable protocol requires subclassing from Parcelable
    is happening even my data class implement
    Parcelable
    interface and annotate with
    @Parcelizee
    , Any kind of hints/context would be appreciated
    :not-kotlin: 1
    z
    e
    y
    • 4
    • 5
  • r

    Rahul Gill

    01/28/2022, 6:07 PM
    How to make a
    Flow
    emit new value on some event(for example emitting new list when an item is added to the list
    a
    • 2
    • 2
  • v

    Vivek Modi

    01/28/2022, 10:48 PM
    Hey I want to filter link from string in kotlin way. For example
    val string = "Check out this property I found using Daft 
        
        <https://www.daft.ie>"
    Output
    <https://www.daft.ie>
    e
    z
    j
    • 4
    • 4
  • u

    Utkarsh Tripathi

    01/29/2022, 6:08 AM
    I want to send image View image from one to another activity and set that image in image view
    :not-kotlin: 2
    z
    • 2
    • 1
  • d

    Devanshu Kaushik

    01/29/2022, 8:03 AM
    Hello, I have an abstract class
    A
    and data class
    D
    such that :
    abstract class A {
      //other fields
      open val qty: Int?
    }
    
    data class D(
      //other fields
      override val qty: Int?
    ): A()
    now, when I use class
    D
    for auto-serializing my JSON response using
    gson
    , I get the following error:
    java.lang.IllegalArgumentException:class D declares multiple JSON fields named qty
    if I’m overriding
    qty
    - won’t it mean that there is actually only one field called
    qty
    ?
    z
    a
    e
    • 4
    • 7
  • f

    Fedora

    01/30/2022, 2:48 PM
    Hey guys; is there a different between ... CoroutineScope(SupervisorJob() + Dispatchers.IO) and ... CoroutineScope(Dispatchers.IO + SupervisorJob()) If yes, which is the correct format?
    j
    g
    • 3
    • 2
  • s

    Slackbot

    01/30/2022, 3:54 PM
    This message was deleted.
    :not-kotlin: 2
    c
    • 2
    • 1
  • r

    Remon Shehata

    01/30/2022, 6:20 PM
    I am building an Android library, is there anyway to create an intent to start an activity the exist in the host app?
    :not-kotlin: 3
    m
    z
    • 3
    • 2
  • n

    Nathaniel Rowe

    01/30/2022, 10:32 PM
    I am using Jetpack Compose, and am trying to communicate a navigation event from the view model back to the screen composable. The idea is that the user enters their username in a text field, hits "Next", and then the view model makes a call to an API to determine whether to use an internal login (in this case we navigate to a password entry screen), or use a web login (in this case we navigate to a screen hosting a WebView). My proof of concept is this:
    typealias NavEventListener<T> = (T) -> Unit
    
    class NavEventDispatcher<T> {
        var listeners = mutableListOf<NavEventListener<T>>()
    
        fun dispatchEvent(value: T) {
            listeners.forEach {
                it(value)
            }
        }
    }
    
    @Composable
    fun <T> HandleNavEvent(dispatcher: NavEventDispatcher<T>, listener: NavEventListener<T>) {
        DisposableEffect(dispatcher) {
            dispatcher.listeners.add(listener)
            onDispose {
                dispatcher.listeners.clear()
            }
        }
    }
    Basically, a screen composable calls
    HandleNavEvent(viewModel.dispatcher) { eventPayload -> onNavigate(...) }
    , and the view model simply adds a dispatcher instance. I have this dispatcher as a second public property of the view model alongside a single state flow describing the UI state. My question is, is there a better way to do this? It seems to work for the most part, I'm new to compose and am wondering if there is anything I'm not considering here. The motivation for this is my architecture has it such that, if we just navigate by watching the UI state, then when we navigate back, you bounce right back to the second screen because the UI state for the previous screen is still one which means "navigate forward". I needed a way to reset the state, and didn't want to have a requirement that all my UI states have a "reset" method which resets only part of it. I figured separating the UI state from the navigation state was the way to go.
    h
    • 2
    • 5
  • k

    Kiki Abdullah

    01/31/2022, 5:59 AM
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val rollButton: Button = findViewById(R.id.roll_button)
            rollButton.setOnClickListener { clickMe() }
        }
    
        private var word = listOf("Bla", "Blabla", "Yo", "Go")
    
        private fun clickMe() {
            val resultText: TextView = findViewById(R.id.result_text)
            val listIndex = 0
            resultText.text = word[listIndex]
            listIndex + 1
        }
    }
    Sorry for this stupid question, I mean to show "Bla" on first click, "Blabla" on second click and so on. but when I run the app, the screen only shows "Bla" even on second or next click. Thanks in advance
    😒olved: 1
    j
    • 2
    • 3
  • c

    Chethan

    01/31/2022, 10:23 AM
    What is best and optimal way to remove all elements but not first element in kotlin mutable list ?
    e
    • 2
    • 1
  • p

    Priya

    01/31/2022, 2:43 PM
    Is there a way to check kotlin coverage% (wrt Java) in the app?
    e
    • 2
    • 1
  • v

    Vivek Modi

    01/31/2022, 3:38 PM
    Hey I am updating kotlinx coroutines to latest version in android. I am getting weird issue on lint check. I updated my version to 
    1.5.1
     to 
    1.6.0
     in my project.
    k
    g
    • 3
    • 18
  • a

    Ali

    01/31/2022, 4:58 PM
    Hello... I have a fun in another usecase layer which return Observable.
    override fun getUpdates(): Observable<Model>
    How can I handle this from the presenter layer using kotlin coroutines? I need scheduler in the presenter layer.e
    g
    • 2
    • 4
  • r

    Rajput Art Studio

    01/31/2022, 5:02 PM
    Hiii team I am using Exoplayer 2.16 But when play mp4 full HD video it return an codec error. Any one please help me how to play mp4 HD video in latest exo player.
    :not-kotlin: 4
    • 1
    • 1
  • l

    Lukasz Kalnik

    01/31/2022, 5:29 PM
    Is there some good practice to test
    ViewModel.onCleared()
    ? It is protected, so cannot be called from tests... I cancel some coroutines jobs there and have to call it at the end of my test. I'm thinking about adding a separate method just for tests which calls
    onCleared()
    internally, but it seems quite ugly.
    u
    • 2
    • 2
  • g

    Guilherme Lima Pereira

    01/31/2022, 7:07 PM
    Did any of you enabled
    android.nonTransitiveRClass=true
    ? I’m wondering what to do with include layout on xml referring a layout from another gradle module, when using databinding.
    :not-kotlin: 3
    f
    • 2
    • 2
  • s

    Scott Kruse

    01/31/2022, 7:18 PM
    Is this the end of synthetics support? https://youtrack.jetbrains.com/issue/KT-50784
    z
    e
    • 3
    • 4
  • s

    Slackbot

    02/01/2022, 8:43 AM
    This message was deleted.
    a
    a
    • 3
    • 2
  • t

    tylerwilson

    02/01/2022, 8:22 PM
    I saw a few days ago a library to construct Android UI with Kotlin, maybe a DSL. Like Anko, but newer and supported. Maybe it was from Square? I can’t find it now. Anybody here know what it might be. Thank you!
    c
    z
    i
    • 4
    • 3
  • u

    ursus

    02/01/2022, 10:01 PM
    I’m trying to install build tools via
    sdkmanager
    on CI, but I get
    sdkmanager "build-tools;30.0.3"
    Warning: Dependant package with key emulator not found!                         
    Warning: Unable to compute a complete list of dependencies.                     
    / #                                     ] 10% Computing updates...
    anybody has a clue please?
    :not-kotlin: 2
    e
    • 2
    • 3
  • j

    jasu

    02/03/2022, 6:52 AM
    This version (1.0.0-beta07) of the Compose Compiler requires Kotlin version 1.4.32 but you appear to be using Kotlin version 1.5.10 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck
    but don't say I didn't warn you!).
    Such a message in exception gives reason to smile 🙃
    g
    • 2
    • 2
  • a

    andreasmattsson

    02/03/2022, 2:19 PM
    Does anyone have any additional information about the Kotlin vulnerability reported in the Q4 2020 Security Bulletin? We have developed an Android app for a client, and as part of security verification need to run a OWASP dependency check, and the only thing that came back flagged that appears on our app's runtime dependencies is CVE-2020-29582. Unfortunately there is very little information on this, and the referenced issue KT-42181 is either private or unexistent.
    e
    j
    • 3
    • 25
  • a

    Ali

    02/03/2022, 3:08 PM
    Anyone knows how can I fill the placeholder
    total
    with the value for this string:
    "%{total} price for the Pizza"
    u
    a
    m
    • 4
    • 12
  • i

    Irene Serrano

    02/04/2022, 12:12 AM
    does anyone know of any good tutorials to send notifications based on a calendar date/time? I'm creating a reminder app and need a way to send notifications or alerts to the user for when it is time to be reminded
    :not-kotlin: 6
    j
    • 2
    • 1
  • s

    Slackbot

    02/04/2022, 12:44 PM
    This message was deleted.
    :not-kotlin: 2
    t
    • 2
    • 1
  • r

    Rafiul Islam

    02/05/2022, 8:44 AM
    In my new project in bumblebee I see something like below in my top level gradle file. I usually see
    com.android.application
    in my module level gradle file.
    plugins {
        id 'com.android.application' version '7.0.0-alpha13' apply false
    }
    And I don' see any dependencies block like
    {
    classpath('com.android.tools.build:gradle:7.0.0-alpha13')
    }
    Don't we need this anymore? How my new project is getting android gradle plugin?
    :not-kotlin: 2
    v
    • 2
    • 1
  • g

    George Pandian

    02/05/2022, 2:10 PM
    Hi all, A question I am creating an Android project using Android Studio IDE, I get the build system configured for the new project (great). I wonder how to change the
    org.gradle.api.initialization.Settings.DEFAULT_SETTINGS_FILE
    It’s a final value which I understand to an extent why , however if I want the settings of the root project to use settings of a buildSrc module I write how can I change it ? I would like to set in my root settings.gradle.kts the name of the DEFAULT_SETTINGS_FILE to “buildSrc/settings.gradle.kts”. Any help appreciated 🙂 also thought on this appreciated more 🙂
    :not-kotlin: 3
    c
    v
    • 3
    • 2
  • s

    spierce7

    02/05/2022, 8:45 PM
    What’s the best way to ensure that no one is mitm and looking at my applications network traffic outside of certificate pinning?
    :not-kotlin: 2
    a
    • 2
    • 2
  • a

    Arjun Achatz

    02/06/2022, 3:26 AM
    QQ : is there an Android slack workspace where people can post these questions that are ignored and marked with "Not Kotlin" ?? It'd be great to have a slack bot to help direct people as well; it would clean up this channel eventually as well so that questions here are actually meant for Kotlin within Android
    i
    t
    • 3
    • 4
Powered by Linen
Title
a

Arjun Achatz

02/06/2022, 3:26 AM
QQ : is there an Android slack workspace where people can post these questions that are ignored and marked with "Not Kotlin" ?? It'd be great to have a slack bot to help direct people as well; it would clean up this channel eventually as well so that questions here are actually meant for Kotlin within Android
i

Ian Lake

02/06/2022, 3:49 AM
As per the channel description:
Using Kotlin to build Android apps. Avoid :not-kotlin:.
:not-kotlin: questions should go here: 😒tackoverflow:; https://discord.com/invite/D2cNrqX, or http://android-united.community/, or https://androidchat.co/
☝️🏻 1
👏 1
🙏 1
👍 2
👍🏻 1
☝️ 2
You might consider asking in #meta about whether a slack bot makes sense
✅ 2
t

therealbluepandabear

02/06/2022, 4:01 AM
AndroidChat is the best place for asking questions, you might want to also consider StackOverflow. I wouldn't recommend the Discord as most people there aren't as knowledgable/experienced as some other communities; your choice though!
A Slack Bot (as Ian Lake/yourself mentioned) is a fantastic idea, I definitely hope it gets added some time in the future.
View count: 8