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

    Юрий

    06/01/2022, 5:20 PM
    Good afternoon, colleagues. How to check the entered value of type :string for the fact that it is not :integer.
    :not-kotlin: 1
    g
    • 2
    • 2
  • g

    Guilherme Delgado

    06/01/2022, 5:29 PM
    Hello! Is there any option to turn on build.gradle*.kts* by default when creating Android projects/modules, etc?
    m
    • 2
    • 5
  • h

    Hank

    06/02/2022, 2:45 AM
    Hello everyone, I wonder is there a tool that can find functions depend on the type of input and output 😅? I’ve decompiled an apk and I cannot see the function names in the apk source code. I guess the functions are Android build-in functions.
    g
    • 2
    • 9
  • r

    Remy Benza

    06/02/2022, 7:45 AM
    https://youtrack.jetbrains.com/issue/KT-44837
    :thread-please: 1
    r
    • 2
    • 2
  • c

    Conrad Kramer

    06/02/2022, 11:34 PM
    I am trying to parse a large JSON response (3 MB), either to
    JsonElement
    or to my custom structure and I am seeing an
    OutOfMemoryError
    every single time. Is this expected? Perhaps I am just close to the Android memory limit?
    :not-kotlin: 1
    s
    • 2
    • 2
  • g

    Guido Perre

    06/03/2022, 7:25 PM
    Hey everyone! I have a question about Gradle configuration with Kotlin DSL in android project. I want to set the classpath of the project in "remote" way. I think the best way to achieve it is with a custom plugin, but i dont quite understand how to do it ¿Does anyone know how to do it? Sorry for my bad English 😁
    c
    • 2
    • 2
  • r

    RE

    06/04/2022, 3:21 AM
    I am trying to use kotlin flow in Service to send data and collect it through Binder in activity. But after testing, flow can only be collected once, is this some cross-process limitation? Is there a better way to listen data changes in service?
    a
    • 2
    • 1
  • s

    Shobana Velmurugan

    06/06/2022, 7:32 AM
    Hi, I integrate Firebase Crashlytics into my app unable to get crash report to Firebase Dashboard. please any one help me Error log : --------- beginning of main 06-06 12:19:47.897 7577 7577 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.4 for vidma.screenrecorder.videorecorder.videoeditor.pro 06-06 12:19:49.011 7577 7748 E FirebaseCrashlytics: Settings request failed. 06-06 12:19:53.764 8553 8553 I FirebaseCrashlytics: Initializing Crashlytics 17.2.1 06-06 12:19:55.118 8553 8778 E FirebaseCrashlytics: Settings request failed. 06-06 12:20:20.393 11343 11343 I FirebaseCrashlytics: Initializing Crashlytics 17.3.0 06-06 12:20:23.049 11343 11416 E FirebaseCrashlytics: Settings request failed. 06-06 12:20:35.474 12324 12324 I FirebaseCrashlytics: Initializing Crashlytics 17.2.1 06-06 12:20:38.450 12324 13013 E FirebaseCrashlytics: Settings request failed. 06-06 12:22:10.134 16037 16094 E FirebaseCrashlytics: Settings request failed. 06-06 12:22:54.911 18209 18209 I FirebaseCrashlytics: Initializing Firebase Crashlytics 17.4.1 06-06 12:22:58.295 18209 18264 E FirebaseCrashlytics: Settings request failed. 06-06 12:22:59.844 18418 18418 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.5 for com.flipkart.android 06-06 12:23:00.905 18418 18537 E FirebaseCrashlytics: Settings request failed. 06-06 12:23:39.682 20031 20031 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.4 for com.weather.Weather 06-06 12:23:40.050 20031 20073 E FirebaseCrashlytics: Settings request failed. 06-06 12:23:47.309 20273 20273 I FirebaseCrashlytics: Initializing Crashlytics 17.2.1 06-06 12:23:50.844 20273 20422 E FirebaseCrashlytics: Settings request failed. 06-06 12:24:21.804 21774 21774 I FirebaseCrashlytics: Initializing Crashlytics 17.2.1 06-06 12:24:23.038 21774 21819 E FirebaseCrashlytics: Settings request failed. 06-06 12:24:27.597 21979 22136 E FirebaseCrashlytics: Settings request failed. 06-06 12:24:38.776 22823 22823 I FirebaseCrashlytics: Initializing Firebase Crashlytics 17.4.1 06-06 12:24:42.118 22823 22874 E FirebaseCrashlytics: Settings request failed. 06-06 12:27:57.856 25169 25169 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.11 for com.ibot.cyrano.android 06-06 12:27:58.125 25169 25373 E FirebaseCrashlytics: Settings request failed. 06-06 12:28:40.534 26610 26610 I FirebaseCrashlytics: Initializing Firebase Crashlytics 17.4.1 06-06 12:28:47.893 27100 27100 I FirebaseCrashlytics: Initializing Firebase Crashlytics 17.4.1 06-06 12:29:48.831 30015 30015 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.11 for com.ibot.cyrano.android 06-06 12:30:19.631 30015 30015 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:30:19.632 30015 30015 D FirebaseCrashlytics: Handling uncaught exception "java.lang.RuntimeException: Cyrano Studio Crash" from thread main 06-06 12:30:19.718 30015 30080 D FirebaseCrashlytics: Loaded userId user123456789 for session 629DA5E403900001753FF252495DEDE7 06-06 12:30:19.758 30015 30080 D FirebaseCrashlytics: Loaded userId user123456789 for session 629DA5E403900001753FF252495DEDE7 06-06 12:30:19.776 30015 30080 D FirebaseCrashlytics: Opening a new session with ID 629DA60303070002753FF252495DEDE7 06-06 12:30:19.781 30015 30080 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:30:19.782 30015 30080 D FirebaseCrashlytics: Logging app exception event to Firebase Analytics 06-06 12:30:19.796 30015 30080 D FirebaseCrashlytics: Sending report through Google DataTransport: 629DA5E403900001753FF252495DEDE7 06-06 12:30:19.827 30015 30080 D FirebaseCrashlytics: Crashlytics report successfully enqueued to DataTransport: 629DA5E403900001753FF252495DEDE7 06-06 12:30:19.827 30015 30080 D FirebaseCrashlytics: Deleted report file: /data/user/0/com.ibot.cyrano.android/files/.com.google.firebase.crashlytics.files.v2:com.ibot.cyrano.android/priority-reports/629DA5E403900001753FF252495DEDE7 06-06 12:30:19.827 30015 30015 D FirebaseCrashlytics: Completed exception processing. Invoking default exception handler. 06-06 12:40:44.982 631 631 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.11 for com.ibot.cyrano.android 06-06 12:40:44.994 631 631 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:40:44.999 631 631 D FirebaseCrashlytics: AnalyticsConnector now available. 06-06 12:40:45.002 631 631 D FirebaseCrashlytics: Registered Firebase Analytics listener. 06-06 12:40:45.005 631 631 D FirebaseCrashlytics: Mapping file ID is: 74828862552e48839200b54bea74c10b 06-06 12:40:45.011 631 631 D FirebaseCrashlytics: Checking for cached settings... 06-06 12:40:45.022 631 631 D FirebaseCrashlytics: Loaded cached settings: {"settings_version":3,"cache_duration":86400,"features":{"collect_logged_exceptions":true,"collect_reports":true,"collect_analytics":false,"prompt_enabled":false,"push_enabled":false,"firebase_crashlytics_enabled":false,"collect_anrs":true,"collect_metric_kit":false},"app":{"status":"activated","update_required":false,"report_upload_variant":2,"native_report_upload_variant":2},"fabric":{"org_id":"6299c056da15fc3820381758","bundle_id":"com.ibot.cyrano.android"},"on_demand_upload_rate_per_minute":10,"on_demand_backoff_base":1.2,"on_demand_backoff_step_duration_seconds":60,"expires_at":1654585189585} 06-06 12:40:45.026 631 819 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:40:45.036 631 819 D FirebaseCrashlytics: Requesting settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/1:132606370287:android:ce1a1a235952533577561a/settings 06-06 12:40:45.080 631 817 D FirebaseCrashlytics: Opening a new session with ID 629DA875001900010277F252495DEDE7 06-06 12:40:45.080 631 631 D FirebaseCrashlytics: Successfully configured exception handler. 06-06 12:40:45.894 631 819 D FirebaseCrashlytics: Loaded settings: {"settings_version":3,"cache_duration":86400,"features":{"collect_logged_exceptions":true,"collect_reports":true,"collect_analytics":false,"prompt_enabled":false,"push_enabled":false,"firebase_crashlytics_enabled":false,"collect_anrs":true,"collect_metric_kit":false},"app":{"status":"activated","update_required":false,"report_upload_variant":2,"native_report_upload_variant":2},"fabric":{"org_id":"6299c056da15fc3820381758","bundle_id":"com.ibot.cyrano.android"},"on_demand_upload_rate_per_minute":10,"on_demand_backoff_base":1.2,"on_demand_backoff_step_duration_seconds":60,"expires_at":1654585845890} 06-06 12:40:45.898 631 817 D FirebaseCrashlytics: Registered Firebase Analytics event receiver for breadcrumbs 06-06 12:40:45.902 631 817 D FirebaseCrashlytics: No userId set for session 629DA60303070002753FF252495DEDE7 06-06 12:42:35.630 2174 2174 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.2.11 for com.ibot.cyrano.android 06-06 12:42:35.644 2174 2174 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:42:35.650 2174 2174 D FirebaseCrashlytics: AnalyticsConnector now available. 06-06 12:42:35.668 2174 2174 D FirebaseCrashlytics: Registered Firebase Analytics listener. 06-06 12:42:35.674 2174 2174 D FirebaseCrashlytics: Mapping file ID is: 74828862552e48839200b54bea74c10b 06-06 12:42:35.682 2174 2174 D FirebaseCrashlytics: Checking for cached settings... 06-06 12:42:35.695 2174 2174 D FirebaseCrashlytics: Loaded cached settings: {"settings_version":3,"cache_duration":86400,"features":{"collect_logged_exceptions":true,"collect_reports":true,"collect_analytics":false,"prompt_enabled":false,"push_enabled":false,"firebase_crashlytics_enabled":false,"collect_anrs":true,"collect_metric_kit":false},"app":{"status":"activated","update_required":false,"report_upload_variant":2,"native_report_upload_variant":2},"fabric":{"org_id":"6299c056da15fc3820381758","bundle_id":"com.ibot.cyrano.android"},"on_demand_upload_rate_per_minute":10,"on_demand_backoff_base":1.2,"on_demand_backoff_step_duration_seconds":60,"expires_at":1654585845890} 06-06 12:42:35.700 2174 2174 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:42:35.762 2174 2174 D FirebaseCrashlytics: Successfully configured exception handler. 06-06 12:42:35.769 2174 2236 D FirebaseCrashlytics: Opening a new session with ID 629DA8E302BA0001087EF252495DEDE7 06-06 12:42:35.816 2174 2236 D FirebaseCrashlytics: Registered Firebase Analytics event receiver for breadcrumbs 06-06 12:42:35.827 2174 2236 D FirebaseCrashlytics: No userId set for session 629DA875001900010277F252495DEDE7 06-06 12:42:50.408 2174 2174 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:42:50.411 2174 2174 D FirebaseCrashlytics: Handling uncaught exception "java.lang.RuntimeException: Cyrano Studio Crash" from thread main 06-06 12:42:50.502 2174 2236 D FirebaseCrashlytics: Loaded userId user123456789 for session 629DA8E302BA0001087EF252495DEDE7 06-06 12:42:50.539 2174 2236 D FirebaseCrashlytics: Loaded userId user123456789 for session 629DA8E302BA0001087EF252495DEDE7 06-06 12:42:50.557 2174 2236 D FirebaseCrashlytics: Opening a new session with ID 629DA8F2022D0002087EF252495DEDE7 06-06 12:42:50.565 2174 2236 D FirebaseCrashlytics: Crashlytics automatic data collection ENABLED by API. 06-06 12:42:50.568 2174 2236 D FirebaseCrashlytics: Logging app exception event to Firebase Analytics 06-06 12:42:50.582 2174 2236 D FirebaseCrashlytics: Sending report through Google DataTransport: 629DA8E302BA0001087EF252495DEDE7 06-06 12:42:50.647 2174 2236 D FirebaseCrashlytics: Crashlytics report successfully enqueued to DataTransport: 629DA8E302BA0001087EF252495DEDE7 06-06 12:42:50.647 2174 2236 D FirebaseCrashlytics: Deleted report file: /data/user/0/com.ibot.cyrano.android/files/.com.google.firebase.crashlytics.files.v2:com.ibot.cyrano.android/priority-reports/629DA8E302BA0001087EF252495DEDE7 06-06 12:42:50.649 2174 2174 D FirebaseCrashlytics: Completed exception processing. Invoking default exception handler.
    :not-kotlin: 10
    :thread-please: 9
    j
    m
    • 3
    • 2
  • v

    Vivek Sharma

    06/07/2022, 8:43 PM
    Anyone know how to display latex equations texts? I searched some libraries but they are not working saying
    android.view.InflateException: Binary XML file line #19 in com.vivek.marksapp:layout/item_question: Binary XML file line #19 in com.vivek.marksapp:layout/item_question: Error inflating class katex.hourglass.in.mathlib.MathView
        Caused by: android.view.InflateException: Binary XML file line #19 in com.vivek.marksapp:layout/item_question: Error inflating class katex.hourglass.in.mathlib.MathView
    :not-kotlin: 1
    • 1
    • 2
  • r

    Robby

    06/08/2022, 5:12 AM
    I have one question my gps location update without device move Any idea? How to resolve?
    :not-kotlin: 3
    e
    • 2
    • 6
  • r

    Robby

    06/08/2022, 7:01 AM
    But, it's regarding Android And i code done in Kotlin
    :not-kotlin: 2
    h
    r
    a
    • 4
    • 4
  • r

    Robby

    06/08/2022, 7:01 AM
    So any one have idea why gps behavior like this
    m
    • 2
    • 1
  • m

    Mitch Ware

    06/08/2022, 8:00 PM
    I have some questions related to the
    kotlin-parcelize
    plugin and how best to use it in a modularized project setup: In an effort to modularize a monolithic Android app module, step 1 (ideally) is to extract common model classes into standalone modules for re-use. Based on the project setup, we want these new modules to be plain JVM modules (no
    com.android.library
    plugin). This becomes problematic if any of the model classes are
    Parcelable
    and utilize the parcelize plugin -
    kotlin-parcelize
    can't run in a module without applying the
    com.android.library
    plugin. Any recommendations on how to work around this? I can come up with two options myself, but neither one is necessarily ideal; I'm curious if anyone has other ideas or recommendations? 1. Make the common model not Parcelable, create a new Parcelize-specific model class local to the app module, and convert back and forth between the two. 2. Persist the data a different way, or use a different serialization strategy, and remove the
    @Parcelize
    annotation on those common models.
    e
    k
    r
    • 4
    • 9
  • m

    Mark Lurie

    06/09/2022, 8:26 AM
    Hey all, I’m trying to implement the okhttp Authenticator to re-authenticate upon access token expiration (401). My question is how to handle when multiple networks calls are sent and return with 401. I tried to annotate the function with @Syncrornized in order to call the remote refresh token API only once instead of for each of the bounced 401 calls. the annotation doesn’t work and i see in the logs that the function that is annotated with it still being called more than once at given time. any suggestion/help?
    :not-kotlin: 1
    s
    n
    • 3
    • 5
  • n

    nuhkoca

    06/10/2022, 3:15 PM
    Hello, how do I write a when clause for density range? I don’t want to hardcode magic numbers
    val scale = when (Resources.getSystem().displayMetrics.densityDpi) {
        DENSITY_MEDIUM -> 1
        ...
        else -> 1
    }
    above works but below not
    val scale = when (Resources.getSystem().displayMetrics.densityDpi) {
        DENSITY_LOW..DENSITY_MEDIUM -> 1 -> // compile error
        ...
        else -> 1
    }
    It gives
    Incompatible types: IntRange and Int
    ✅ 1
    l
    • 2
    • 2
  • v

    Vivek Modi

    06/10/2022, 10:27 PM
    Hey Guys, I am looping and deleting the element from the same list in kotlin. So I am getting error so what is way of doing that.
    Exception in thread "main" java.util.ConcurrentModificationException
    	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013)
    	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:967)
    	at ChipDataKt.main(ChipData.kt:72)
    	at ChipDataKt.main(ChipData.kt)
    :stackoverflow: 2
    e
    c
    • 3
    • 7
  • n

    Natalia Chuzhmarova

    06/11/2022, 11:40 PM
    Hi there! In many articles about collecting Flow in an Android lifecycle aware manner there is
    SharingStarted.WhileSubscribed(5000L)
    in
    stateIn
    operator. Where does the 5000 come from? Why not zero and why exactly that number? Thanks in advance.
    a
    • 2
    • 4
  • f

    Freedom

    06/12/2022, 4:04 PM
    I have a Database entity and DTO and a domain model I mapped the network DTO to my domain model in a usecase that fetching a list of item Now I have another usecase that fetches from cache storage But would be observed in the same fragment as the first one which is the list of item form network Usecase 1 fetch from API Map to domain model observed in view in a recycler view Usecase 2 user saved a particular article to disk I then fetch from cache storage and observe in the same view in another recycler view My question is should I create a different domain model for that of cache Entity and for DTO Because in the view model I have a UI state For example
    data class UIState(
    val itemlist = List<ItemEntity> = list of()
    Val isLoading ......
    )
    If I update itemlist uiState with data fetched from network How can I differentiate it from data fetch from cache because I need these distinctive data in 2 different recycler view
    • 1
    • 1
  • v

    Vivek Modi

    06/13/2022, 9:35 AM
    Hey guys, I want to combine flow and string. I am trying to do that, but I am getting problem.
    viewmodel.kt
    private val query = MutableStateFlow("")
    var queryText: String
        get() = query.value
        set(value) {
            query.value = value
        }
    val filteredTopics = MutableStateFlow<List<ConsulationsTopics>>(emptyList())
     val filteredCategories = query
            .debounce(200) // low debounce because we are just filtering local data
            .distinctUntilChanged()
            .combine(filteredTopics) { queryText, categoriesList ->
                val criteria = queryText.lowercase()
                if (criteria.isEmpty()) {
                        return@combine filteredTopics
                } else {
                    categoriesList.filter { category -> category.title?.lowercase()?.let { criteria.contains(it) } == true }
                }
            }
    • 1
    • 2
  • s

    Sergio C.

    06/13/2022, 9:36 AM
    Hi, has anyone encountered this issue with Kotlin 1.7.0 and Hilt?
    error: [Hilt]
    Unsupported metadata version. Check that your Kotlin version is >= 1.0: java.lang.IllegalStateException: Unsupported metadata version. Check that your Kotlin version is >= 1.0
    How can I solve this? using
    implementation 'com.google.dagger:hilt-android:2.42'
    kapt 'com.google.dagger:hilt-android-compiler:2.42'
    kapt 'androidx.hilt:hilt-compiler:1.0.0'
    classpath('com.google.dagger:hilt-android-gradle-plugin:2.40.1')
    j
    j
    • 3
    • 8
  • k

    Kiki Abdullah

    06/13/2022, 2:18 PM
    I create a background task to refresh the token for user but it throw NPE even though I have cast the variable in the end. Anyone know what I should do?
    private var result: Result? = null
        private lateinit var data: Data
    
        override fun doWork(): Result {
            val refreshToken = inputData.getString(REFRESH_TOKEN)
            APIConfig.getAuthAPIService().refreshToken("refreshToken=$refreshToken")
                .enqueue(object : Callback<LoginResponse> {
                    override fun onResponse(
                        call: Call<LoginResponse>,
                        response: Response<LoginResponse>
                    ) {
                        if (response.isSuccessful) {
                            val token = response.body()?.loginData?.accessToken.toString()
                            Log.e("token from TokenWorker ", token)
                            data = workDataOf(NEW_TOKEN to token)
                            result = Result.success(data)
                        }
                    }
    
                    override fun onFailure(call: Call<LoginResponse>, t: Throwable) {
                        Log.e(TAG, "onFailure: ${t.message}")
                        result = Result.failure()
                    }
                })
            return result as Result
        }
    m
    • 2
    • 1
  • s

    Slackbot

    06/13/2022, 3:03 PM
    This message was deleted.
    c
    • 2
    • 1
  • a

    Advitiay Anand

    06/13/2022, 3:22 PM
    Hey everyone 😄 Can anyone look at this snippet and tell me why
    listOfRides.map { ... }
    freezes the app?
    private fun initUserAndRides() {
    
        // TODO: Fix this
        viewModelScope.launch {
    
            val userInstance = repository.getUser()
            val listOfRides =
                repository.getRides()
    
            _user.postValue(userInstance)
    
            withContext(Dispatchers.Default) {
                val listOfUserRides = listOfRides.map { UserRide.createUserRide(userInstance, it) }
                _rides.postValue(listOfUserRides)
            }
        }
    }
    Please know that
    UserRide.createUserRide(userInstance, it)
    is computationally-expensive. Also,
    repository.getUser()
    and
    repository.getRides()
    are suspend functions implemented by Retrofit.
    s
    • 2
    • 4
  • o

    Orhan Tozan

    06/14/2022, 8:52 AM
    In an Android project, how do I create/maintain a CoroutineScope that has the lifetime of a logged in user? Something like a
    UserScope
    b
    • 2
    • 8
  • m

    Mustafa Selim Özen

    06/15/2022, 7:34 AM
    Hello everyone. I wrote an article about kotlin. I didn't publish yet. Can anyone read and comment? Can you help me?
    • 1
    • 1
  • a

    Artem Kopan

    06/15/2022, 7:22 PM
    Hi everyone. I’m working with legacy project and project has sub-projects. Structure looks like:
    root_folder:
    - build.gradle - top build
    - /project1/build.gradle
    - /project2/build.gradle
    I wanna update kotlin version only for project 1 but I faced with issues, because kotlin version is defined in top build file. Is there any workaround how to re-define kotlin version, android gradle plugin version only in /project1/build.gradle?
    e
    • 2
    • 2
  • s

    Slackbot

    06/15/2022, 11:38 PM
    This message was deleted.
    :not-kotlin: 3
    :yes: 1
    j
    • 2
    • 1
  • j

    jay shah

    06/16/2022, 11:18 AM
    Is
    ?.let
    not thread safe?
    g
    e
    d
    • 4
    • 10
  • j

    jay shah

    06/16/2022, 11:29 AM
    So both
    ?.let
    and
    ?:
    are thread safe? because using
    if
    gives me smart cast error
    :thread-please: 2
    g
    j
    • 3
    • 3
  • c

    chi

    06/16/2022, 2:13 PM
    Hello folks, has when expression always required being exhaustive for sealed classes or enums? My code use to work without the else but it seems like there's a recent change in the new Kotlin version (not stated in the changelog) that now enforces this, is that the case?
    e
    r
    • 3
    • 4
Powered by Linen
Title
c

chi

06/16/2022, 2:13 PM
Hello folks, has when expression always required being exhaustive for sealed classes or enums? My code use to work without the else but it seems like there's a recent change in the new Kotlin version (not stated in the changelog) that now enforces this, is that the case?
e

ephemient

06/16/2022, 2:15 PM
https://kotlinlang.org/docs/whatsnew1530.html#exhaustive-when-statements-for-sealed-and-boolean-subjects 1.6: warning 1.7: error
☝️ 1
c

chi

06/16/2022, 2:17 PM
Thanks!
r

Robert Williams

06/16/2022, 2:40 PM
Note there’s a difference between when expression (
=when {
) and when statement (
when {
)
👍 1
when expression has always required exhaustive
View count: 19