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

    Breaker ACT

    01/11/2022, 4:35 AM
    Sorry if my question is not Kotlin 😄 I am facing with navigation component issue. I am trying to navigate to a screen inside a navFragmentContainer. It work fine but after I navigateUp (or popBackStack) I got a bank screen. Any idea for my issue, thanks!!
    😄 1
    👀 1
    :not-kotlin: 2
    u
    • 2
    • 4
  • m

    Milan Vadhel

    01/11/2022, 10:06 AM
    Hi, I am working on location based app. Right now i am giving the android 12 support. I have done with all location permission related changes. In our app we have integrated sendbird sdk for call. So when i try to call then app is crashing with
    java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@57f2dd45: AdapterService getBondedDevices
    Even though my app does not any requirement for bluetooth related feature. Does anyone know about this exception?
    :not-kotlin: 4
    p
    h
    p
    • 4
    • 4
  • a

    Akhil Jain

    01/11/2022, 11:08 AM
    Hello All, I am trying migrating my app to android 12 by changing the target SDK version to 31 in build.gradle. As required, I have added 
    android:exported
     flag to every activity/receiver/services/provider tags present in my manifest file. But still I am getting this error.
    Manifest merger failed : android:exported needs to be explicitly specified for <receiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined.
    So I am guessing this issue is due to any 3rd party library whose manifest contains a receiver without 
    android:exported
     flag. I have also checked merged manifest file for missing 
    android:exported
     in components of any third party libraries. But in merged manifest file also all activity/receiver/services tags has exported flag. So how can I find that missing receiver which is causing the issue.
    :not-kotlin: 3
    r
    p
    a
    • 4
    • 8
  • a

    Asim Khatri

    01/11/2022, 12:47 PM
    Hi, what is the equivalent of CheckStyle for Kotlin https://checkstyle.org/index.html
    p
    e
    • 3
    • 4
  • l

    Lucca Beurmann

    01/11/2022, 5:52 PM
    Hello everyone, i'm writing unit tests in my VM using a mockk and Turbine combination but i'm facing an interesting problem in this test:
    @Test
    fun `Should show api error when create request token fails`() = runTest {
        every { loginRepository.createRequestToken() } returns flow {
            emit(
                Source.Error(
                    NetworkError(400, "error")
                )
            )
        }
    
        viewModel.events.test {
    
            viewModel.onLoginClick()
    
            verify(exactly = 1) { loginRepository.createRequestToken() }
            confirmVerified(loginRepository)
    
            Truth.assertThat(viewModel.isButtonLoading.value).isFalse()
    
            Truth.assertThat(awaitItem())
                .isInstanceOf(LoginEvents.ShowApiError::class.java)
    
            cancelAndConsumeRemainingEvents()
        }
    }
    When i run this test the Truth assert that verifies the event succeeds, but mockk throws an error saying that repository,createRequestToken() wans't called
    p
    • 2
    • 2
  • f

    Fabio Rachid

    01/11/2022, 10:14 PM
    b
    t
    • 3
    • 2
  • t

    Tong Zhang

    01/13/2022, 6:34 AM
    public abstract class Task<TResult> {
        public Task() {
        }
    
    
        public abstract <X extends Throwable> TResult getResult(@NonNull Class<X> var1) throws X;
    
        @Nullable
        public abstract Exception getException();
        
    }
    java getResult method how to convert to koltin code
    abstract class Task<TResult> {
    
        @Throws(X::class)
        abstract fun <X : Throwable> getResult(var1: Class<X>): TResult
    
    }
    ➕ 2
    d
    • 2
    • 4
  • o

    Oleksii

    01/13/2022, 3:24 PM
    Hi, I'm new to android development, but I want to create an app. I found GitHub repositories useful for learning. Can you please share some good Kotlin android repositories? 🙇‍♂️
    s
    • 2
    • 3
  • v

    Vivek Modi

    01/13/2022, 4:27 PM
    Hey guys. Can someone know how to update list in MutableStateFlow . When I am adding more value, my previous value will drop. Please someone guide me
    z
    g
    • 3
    • 11
  • i

    Igor Milakovic

    01/13/2022, 5:23 PM
    Apologies for a probably off-topic question, but can anyone please point me towards the best practices for navigation in Android? Specifically, I'm wondering whether I should use the Navigation component or not. Also, my understanding is that Fragments are preferred over activities. So when I want to push (sorry, coming from iOS development! 🙂) a new screen, should I start a new
    Intent
    and host my
    NewScreenFragment
    in the
    NewActivity
    ? Or is it better to just replace the
    CurrentScreenFragment
    with
    NewScreenFragment
    (and add it to back stack) in the
    CurrentActivity
    and then adjust the action bar (back button, menus etc)? Finally, to top it all off, I want to apply the coordinator pattern on all that so I don't tight couple the flows within Activities/Fragments. Thank you very much in advance!
    :not-kotlin: 3
    u
    • 2
    • 3
  • a

    Ameen Essa

    01/14/2022, 1:47 AM
    Hello, if anyone uses the Macbook Air with M1 chip it is worth for Android Development.
    :not-kotlin: 8
    x
    u
    +3
    • 6
    • 6
  • a

    Arun Joseph

    01/14/2022, 9:06 AM
    Is there a pure kotlin library alternative for android.icu.text.StringSearch ?
    • 1
    • 1
  • m

    Massimo Canonico

    01/14/2022, 11:19 AM
    Hi everyone. Once I have connected my app to a firebase project, can I change it? I mean, change the firebase project by keeping the same app.
    :not-kotlin: 8
    y
    • 2
    • 2
  • m

    Massimo Canonico

    01/14/2022, 11:19 AM
    Where can I find info about which firebase project is connected to my app? Thank you very much in advance.
    u
    • 2
    • 2
  • v

    Vivek Modi

    01/14/2022, 2:47 PM
    Hey I am working in Android Kotlin. I am learning this LatestNewsUiState sealed class example from Android doc. I made my own 
    sealed class
     example. But I am confused little bit, how can I achieved this. Is I am doing right for my scenario or not?
    • 1
    • 2
  • f

    Francesc

    01/14/2022, 5:18 PM
    if I have a
    sealed interface
    within a
    sealed interface
    I can't have an exhaustive when with the outer
    sealed interface
    entries (see example in thread). What's the reason for this?
    e
    • 2
    • 3
  • s

    spierce7

    01/14/2022, 7:28 PM
    Something I’ve been confused about - Is certificate pinning still a best practice on Mobile? The web community has basically stopped the practice completely, and I always hate having to deal with the certificate upgrades every year or 2. Is there a better way that I’m just not informed of yet?
    j
    e
    +4
    • 7
    • 20
  • r

    Roudy Korkis Kanaan

    01/17/2022, 10:57 AM
    Hello, I'm trying to suppress optin warnings module wide by adding the compile args in my gradle file. The exact same compiler args work just fine on another project with same AS version and gradle plugin but for some reason for this project the warning doesn't go away, the app builds and runs but the warning stays. removing the optins from gradle will result in an error, so they are working but the warnings aren't removed. Here's my gradle file: https://github.com/roudikk/compose-navigator/blob/master/sample/build.gradle.kts
    • 1
    • 1
  • m

    Marcin Wisniowski

    01/17/2022, 10:59 AM
    In the architecture guide https://developer.android.com/jetpack/guide/ui-layer/events#handle-viewmodel-events it is suggested to model navigation as state updates instead of events. It makes sense, but how to best model it in a way which avoids navigating away multiple times? On screen A the state changes in a way that signifies screen B should be shown. In response, screen A navigates to screen B. All is fine. Then the user presses back. We are on screen A, but it will just immediately navigate to screen B since the state didn't change. How to handle that?
    a
    • 2
    • 5
  • a

    Alaa Al

    01/17/2022, 4:31 PM
    Hello all,
    private val _qualifications: MutableStateFlow<List<QualificationView>?> = MutableStateFlow(null)
    val qualifications:StateFlow<List<QualificationView>?> = _qualifications
    I’m trying to use qualifications between parent fragment and bottomSheet, but consumer collects list just once.  Screenshot of the code below.
    h
    • 2
    • 1
  • v

    Vivek Modi

    01/17/2022, 10:53 PM
    Hey I am working in kotlin flow in android. I noticed that my kotlin flow
    collectLatest
    is calling twice and sometimes even more. I printed the log inside my
    collectLatest
    function it print the log.
    m
    • 2
    • 11
  • a

    An Tran

    01/18/2022, 3:39 AM
    hi guys, anyone know how to display pdf using jetpack compose ?
    w
    • 2
    • 1
  • m

    Massimo Canonico

    01/18/2022, 10:49 AM
    Expecting a top level declaration
    m
    • 2
    • 2
  • m

    Massimo Canonico

    01/18/2022, 10:58 AM
    but android studio does not suggest me this and neither adding this "import coil.load" works, I get an error even in this import too
    :thread-please: 3
    h
    c
    • 3
    • 7
  • v

    Vivek Modi

    01/18/2022, 11:13 AM
    Hey I am working in json response with html tag in kotlin. I don't understand how to parse html tag in response. I tried to work with retrofit and moshi. My response will look like this
    • 1
    • 1
  • f

    Fedora

    01/18/2022, 4:08 PM
    Hi, I have the stupidest question on creating a simple data structure in Json format! Im somewhat confused when i tried creating it via mutableMapOf.. mutableListOf etc and the output is not like below. Anybody knows a simple kotlin magic to create this output:
    [
    {
    "type" : "food",
    "value" : "pizza, buger, pasta"
    },
    {
    "type" : "drink",
    "value" : "soda, Mountain Dew, redbull"
    }
    ]
    c
    c
    g
    • 4
    • 10
  • u

    Umar Ata

    01/18/2022, 5:50 PM
    Hi I have a kotlin data class, initially it had 200 parameters in constructor and was working fine, at some point I got it updated as the data is coming from server and I need to add as many new parameters gets added to one JSON object and then I did. But as soon as parameters increased to 300 it started giving error like Bad class exception I am now somewhat confused. So to overcome this i created a plain POJO class in Java and it is working fine. Is there any documentation or solution I apply and use kotlin data class instead of POJO Am I missed something? Currently my server returning more than 500 strings in one JSON object
    :blob-thinking-upside-down: 1
    :blob-nervous: 2
    😱 9
    h
    z
    +6
    • 9
    • 23
  • a

    Ali

    01/19/2022, 12:14 PM
    I have scenario like this:
    data class A(
        val metadata: String
    ){
        data class B(
            val metadata: String
        )
    }
    
    fun updateData(data: Any){
        when(data){
            is A -> {// update A metadata value
            }
            is A.B -> {// update B metadata value
            }
        }
    }
    want to update the value of
    metadata
    for both data class by using the same logic and don't want to write it twice inside when statement. How can I do it by writing the logic only once?
    j
    u
    • 3
    • 6
  • r

    Rahul Ray

    01/19/2022, 2:45 PM
    I want to add applicationIdSuffix for staging buildtype like this
    staging {
        applicationIdSuffix ".staging"
    }
    but I am getting this error
    Caused by: org.gradle.api.GradleException: No matching client found for package name
    I can fix this by creating seperate sourceSets and put seperate google_services.json files in them. Now I don't want to create seperate sourceSets for staging and prod build types. Can anyone suggest me a solution to this?
    :not-kotlin: 5
    d
    • 2
    • 1
  • r

    Rizwan Minhas

    01/19/2022, 3:19 PM
    Hi, anyone who integrated RevenueCat sdk in android for google play billing ? Is it Ok to use it instead of google play billing library?
    :not-kotlin: 4
    h
    m
    • 3
    • 5
Powered by Linen
Title
r

Rizwan Minhas

01/19/2022, 3:19 PM
Hi, anyone who integrated RevenueCat sdk in android for google play billing ? Is it Ok to use it instead of google play billing library?
:not-kotlin: 4
h

heckfyxe

01/19/2022, 4:11 PM
Yep, it works fine and it's easier to integrate than original google billing library. It's just wrapper for official library
r

Rizwan Minhas

01/20/2022, 12:05 PM
and google is not going to object it while reviewing?
h

heckfyxe

01/20/2022, 2:00 PM
Google doesn't have any restriction for it. I would say, Google even provides API for working with billing and revenue cat uses this API
r

Rizwan Minhas

01/20/2022, 2:02 PM
Thanks
m

Mark Sheekey

01/25/2022, 8:46 PM
As above, very simple to use and no problems with Google.
View count: 8