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

    Slackbot

    10/11/2021, 10:37 AM
    This message was deleted.
    :thread-please: 1
    g
    v
    • 3
    • 5
  • s

    Shaheer Muzammil

    10/11/2021, 2:30 PM
    Hey guys, Are normal function calls in suspend function, sequential? For Example; in the snippet below, will the liveData post empty list or wait for the suspend call to finish and post that list?
    var dataList = emptyList()
    fun suspend fetchData(){
        dataList = repository.getData() //another suspend function
                             .map{/* some mapping logic */}
        liveData.postValue(dataList)
    }
    I have this scenario and an empty list is being printed.
    m
    n
    • 3
    • 5
  • s

    spierce7

    10/11/2021, 8:44 PM
    A few years ago, Kotlin reached the #2 spot for most loved language on SO survey. Why is Kotlin so far down this year?
    c
    • 2
    • 8
  • a

    Ashu

    10/12/2021, 5:34 AM
    I just updated multiple things in my project like AGP & Kotlin version and now I am getting this error on build:
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during file facade code generation
    File being compiled: <file://D>:/........../FirebaseMessagingService.kt
    The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.com.intellij.openapi.diagnostic.DefaultLogger.error(DefaultLogger.java:53)
    What is this error?
    g
    • 2
    • 3
  • a

    Ashu

    10/12/2021, 8:21 AM
    If arguments of a function in Java are annotated with neither
    @Nullable
    nor
    @NotNull
    , what is it considered in Kotlin. Normally it would be allowed to pass nullable arguments but I have updated Kotlin version and now it is taking them as non-nullable arguments and throwing error. Did this change?
    e
    • 2
    • 2
  • m

    Milan Vadhel

    10/12/2021, 11:42 AM
    Hello all, Any one have used GraphQL with Android?
    :not-kotlin: 4
    d
    e
    • 3
    • 6
  • v

    Vivek Modi

    10/12/2021, 2:51 PM
    Hey I am working to create a list of type INCOMING, OUTGOING and TIME through enum class. My data class is populated through api call and filled according to that in the list. I want to modify to add TIME enum value whenever date ends the current one.
    g
    • 2
    • 10
  • s

    shahroz

    10/12/2021, 2:53 PM
    Hey folks, trying to understand if there could be a possible memory leakage in this case. I have created a SingletonClass with private members, one of the private member is another class which then holds reference of repositories etc. So now since, there is a singleton instance of my class, which further has strong reference to other member classes, can there be any scare of
    memory leakage
    ?
    g
    • 2
    • 2
  • s

    Se7eN

    10/12/2021, 4:52 PM
    I'm trying to migrate my project to the new activity result API. I have a
    PermissionUtils
    that takes care of checking/requesting permissions:
    object PermissionUtils {
        fun checkPermissions(context: Context, permissions: List<String>, listener: PermissionListener) {
            // uses a library that checks for permissions and calls listener.onPermissionsGranted() or listener.onPermissionsDenied()
        }
    }
    Now, to use the new activity result API, I'd have to register the contracts in each activity, which doesn't sound good because I have many activities and all of them would look like this:
    class MyActivity : AppCompatActivity {
        val imageFromGallery = registerForActivityResult(RequestMultiplePermissions()) { 
            ...
        }
    
        val takePicture = registerForActivityResult(RequestMultiplePermissions()) { 
            ...
        }
    
        val shareImage = registerForActivityResult(RequestMultiplePermissions()) { 
            ...
        }
    }
    Is it possible to incorporate this logic into the
    checkPermissions()
    function itself?
    i
    • 2
    • 5
  • l

    Lilly

    10/12/2021, 5:02 PM
    Would it be difficult to write a CSV parser that maps lines to a data class based on annotations? The first question would be what I need to declare own annotations. Do I have to create a compiler that interprets these annotations? Edit: I know there are CSV libraries out there. It's for the learning effect.
    c
    e
    • 3
    • 40
  • k

    Katarzyna

    10/13/2021, 7:31 AM
    How do we generally define coroutine scope on Android and on the backend? Constructing coroutine scope by @marcinmoskala https://kt.academy/article/cc-constructing-scope
    g
    m
    • 3
    • 11
  • m

    Mohan Babu Malairaj

    10/13/2021, 7:33 AM
    hi, jacoco 0.8.7 is not working with kotlin 1.5.31 but it works with 1.4 btw. Is there a way to resolve this ? Or is there an alternate to jacoco for code coverage ?
    w
    i
    • 3
    • 4
  • s

    Slackbot

    10/13/2021, 3:54 PM
    This message was deleted.
    a
    k
    • 3
    • 2
  • a

    Android75

    10/14/2021, 3:08 AM
    a simple question, i remember the possibility to run simple kotlin file in Android Studio without launch app, like a playground.
    a
    a
    • 3
    • 2
  • i

    iamraghavawasthi

    10/14/2021, 8:13 AM
    What would be the correct approach to do this. I am getting an error
    e
    d
    l
    • 4
    • 4
  • v

    Vivek Modi

    10/14/2021, 9:38 AM
    Hey Guys, I have enum class and I am mapping by value, when I am return Enum value it always complain about null issue.
    enum class ConversationStatus(val status: String) {
        OPEN("open"),
        CLOSED("closed");
    
        companion object {
            private val mapByStatus = values().associateBy(ConversationStatus::status)
            fun fromType(status: String): ConversationStatus {
                return mapByStatus[status]
            }
        }
    }
    How can i avoid this ?
    g
    d
    b
    • 4
    • 11
  • b

    Billy Newman

    10/14/2021, 1:22 PM
    Anyone know if there is a kotlin coroutine implementation of java.io.File? EG, non blocking calls for things like createNewFile() and ZipFile(…)
    e
    • 2
    • 2
  • s

    spierce7

    10/14/2021, 7:56 PM
    What is the proper way to use the `
    plugins.withType<com.android.build.gradle.LibraryPlugin> { }
    in Gradle Kotlin Script DSL? I’m trying to configure multiple gradle modules via the gradle
    submodules
    block in the root build.gradle.kts. I’ve never been able to figure out how to do this though.
    a
    j
    • 3
    • 7
  • g

    gilsonjuniorpro

    10/14/2021, 9:14 PM
    I already have this function fun replaceArabicNumbers(number: String): String{ return number .replace("٠", "0") .replace("١", "1") .replace("٢", "2") .replace("٣", "3") .replace("٤", "4") .replace("٥", "5") .replace("٦", "6") .replace("٧", "7") .replace("٨", "8") .replace("٩", "9") }
    :stackoverflow: 2
    :thread-please: 2
    e
    j
    • 3
    • 7
  • o

    Osip Fatkullin

    10/15/2021, 11:37 AM
    Just released this tiny library to encrypt DataStore using Tink.
    This library will be maintained until an official solution for DataStore encryption will be released by Google.
    👍 2
    l
    t
    • 3
    • 4
  • r

    reactormonk

    10/15/2021, 12:34 PM
    I loaded https://github.com/corona-warn-app/cwa-app-android into vscode, and the language server gives me lots of errors, e.g.
    None of the following functions can be called with the arguments supplied: 
    public/*package*/ constructor Module(loader: ClassLoader!) defined in java.lang.Module
    public/*package*/ constructor Module(loader: ClassLoader!, descriptor: ModuleDescriptor!) defined in java.lang.Module
    public/*package*/ constructor Module(layer: ModuleLayer!, loader: ClassLoader!, descriptor: ModuleDescriptor!, uri: URI!) defined in java.lang.Modulekotlin(NONE_APPLICABLE)
    I'm not even sure how to debug that. Looks like the language server doesn't have all the source loaded?
    :not-kotlin: 1
    c
    • 2
    • 8
  • n

    Nayan Gandhi

    10/15/2021, 6:25 PM
    Hi Everyone, We have an Android SDK written in Kotlin. Our SDK can be consumed in Apps written in Kotlin as well as Java. We're trying to add an optional method in an interface (i.e with default implementation 
    fun method(){}
    ). Kotlin based Apps won't complain about new method while Java based Apps will complain about implementing the new method added to the interface. Is there any thing we can do so that it's not a breaking change for Java based apps?
    g
    e
    • 3
    • 2
  • v

    Vivek Modi

    10/15/2021, 10:38 PM
    Hey I want to call a PUT http request. I want to parallel asynchronous call multiple times with different id. So how can be possible to do in efficient way. Do i need to use flow ?
    n
    • 2
    • 4
  • r

    reactormonk

    10/17/2021, 9:28 AM
    I'm trying to load an android project into intellij, but it fails via
    > This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2020.3.1 or newer.
    > Failed to stop service 'com.android.build.gradle.internal.errors.SyncIssueReporterImpl$GlobalSyncIssueService_4e280c73-f191-497b-9e82-c0aa147e7cbd'.
       > Failed to find target with hash string 'android-30' in: /opt/android-sdk
    I can't find the android support plugin in the settings, intellij version 2021.2.2 I ran
    sdkmanager "platforms;android-30"
    So the platform should be installed.
    :not-kotlin: 2
    😉 1
    a
    c
    • 3
    • 2
  • l

    Lukas K-G

    10/18/2021, 6:52 AM
    When using a third party library, which type of logger would you prefer that the lib is using? 1️⃣ slf4j 2️⃣ Timber 3️⃣ let me provide my own implementation of a logger interface to the library 4️⃣ something else, please state in the comment. If you would take your time and comment a reason why would be highly appreciated.
    1️⃣ 1
    4️⃣ 1
    3️⃣ 16
    2️⃣ 5
    g
    g
    +2
    • 5
    • 15
  • s

    Slackbot

    10/18/2021, 8:02 AM
    This message was deleted.
    g
    d
    • 3
    • 2
  • r

    Rodrigo

    10/18/2021, 1:17 PM
    Hello guys, i dont know if any of you have passed through a situation like that, but, an open source lib i was using (https://github.com/rozkminiacz/DirectionsSDK) was published with bintray .... and now that its offline, i cant even get the clients project to build ... do you have any tips? thanks
    t
    v
    • 3
    • 2
  • p

    PanicMonster

    10/18/2021, 3:03 PM
    hello. I have two Kotlin classes -> Human and Main. Human is a model class which has private var - name, age, address, language. I want to create a Human instance in Main and access all of its data fields. In Java, we used to implement getter and setter for each field. What is the tradition in Kotlin? and also, how do we generate getter setter like we used to do for Java?
    u
    k
    • 3
    • 4
  • v

    Vivek Modi

    10/19/2021, 8:25 AM
    hey i have list. I want to update item on top of list. So which way is efficient in performance, memory management etc.
    fun main() {
        val listOne = mutableListOf(2, 3)
        listOne.add(0, 1)
        println(listOne)
    
        var listTwo = mutableListOf(2, 3)
        listTwo = (mutableListOf(1) + listTwo).toMutableList()
        println(listTwo)
    }
    what's the d/w both example?
    r
    i
    s
    • 4
    • 16
  • f

    Fernando de Paula

    10/19/2021, 12:15 PM
    good morning ! What the "!!" means ?
    u
    s
    +3
    • 6
    • 16
Powered by Linen
Title
f

Fernando de Paula

10/19/2021, 12:15 PM
good morning ! What the "!!" means ?
u

Umar Ata

10/19/2021, 12:20 PM
https://kotlinlang.org/docs/null-safety.html
f

Fernando de Paula

10/19/2021, 12:26 PM
thanks!!!
s

Syed Ovais Akhtar

10/19/2021, 12:59 PM
? Means can be null and !! Means can't be null For example we have locations which can be null so we can write
location?.let {
// do something if not null
} ?: run {
// Do something if null
}
And
location!! // Is not null
@Fernando de Paula
u

Umar Ata

10/19/2021, 1:07 PM
location!! will produce crash if it is null it is only use when you are sure that property will not be null at a particular condition
k

Kamil Kalisz

10/19/2021, 1:07 PM
!!
cast nullable object to non nullable object. If that object is null that operation will throw NullPointerException
s

Syed Ovais Akhtar

10/19/2021, 1:08 PM
@Umar Ata of course yes
f

Fernando de Paula

10/19/2021, 1:09 PM
very nice!
it is dangerous
u

Umar Ata

10/19/2021, 1:10 PM
try to avoid using !! and just use location?.let{ print(it.lat) } and this let will only trigger when location is not null
f

Fernando de Paula

10/19/2021, 1:13 PM
"it" is like "this" ?
s

Syed Ovais Akhtar

10/19/2021, 1:14 PM
It keyword will makes reference of location variable
k

Kamil Kalisz

10/19/2021, 1:15 PM
it depends of method. let/run/apply etc…
https://kotlinlang.org/docs/scope-functions.html#function-selection
u

Umar Ata

10/19/2021, 1:15 PM
https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F45[…]e=images&amp;cd=vfe&amp;ved=0CAsQjRxqFwoTCKi8-ozH1vMCFQAAAAAdAAAAABAD
n

nfon jeannoel

10/19/2021, 4:57 PM
Way of assuring that the value will not be null. This is to bypass the null check
g

gildor

10/20/2021, 3:52 AM
I recommend #getting-started for such discussions, Android channel doesn’t look relevant to this
👍 1
View count: 4