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

    Eileen

    01/08/2020, 2:07 PM
    Does anybody if the banner component from material UI is available in android now?
    :stackoverflow: 1
    n
    z
    2 replies · 3 participants
  • c

    Can

    01/08/2020, 5:46 PM
    When opening the softkeyboard (on relayout) the recyclerview jumps in its scroll state for whatever reason
    w
    4 replies · 2 participants
  • j

    Joey

    01/09/2020, 8:07 AM
    anyone encounter this error?
    6 exceptions were raised by workers android
    n
    1 reply · 2 participants
  • k

    KamilH

    01/09/2020, 9:57 AM
    I have a simple
    Flow
    wrapper around
    LiveData
    and I have a problem, because it closes (
    invokeOnClose
    is called) immediately after first value is emitted by
    Observer
    .
    fun <T> LiveData<T>.asFlow(): Flow<T> = channelFlow {
        value?.let { offer(it) }
        val observer = Observer<T> { t -> t?.let(this::offer) }
        observeForever(observer)
        invokeOnClose {
            removeObserver(observer)
        }
    }
    To be sure my
    CoroutineScope
    is not causing this cancellation, I run this also in
    GlobalScope
    and the behaviour was the same. How can I see what is causing cancellation? I analysed stack trace, but I didn’t see anything interesting there.
    a
    d
    6 replies · 3 participants
  • a

    Ashutosh Panda

    01/09/2020, 1:47 PM
    Hi Guys I have doubt about passing data between fragments and here is the questio https://stackoverflow.com/questions/59622490/passing-data-between-data-fragments
    s
    1 reply · 2 participants
  • o

    Ofir Bar

    01/09/2020, 8:15 PM
    hey guys, I know it sounds stupid but why don’t I get ANR? I am blocking the main thread for 10 seconds. I also tried Thread.sleep(10000)
    🤔 1
    h
    a
    +3
    10 replies · 6 participants
  • a

    A

    01/09/2020, 8:51 PM
    Hi, not a kotlin can anyone tell me why can't i subscribe to this observable? in all aticles i have read, the observeable has a function subscribe where we can get the live updates (I am new to rxjava)
    s
    2 replies · 2 participants
  • m

    myanmarking

    01/10/2020, 5:50 PM
    is any1 using cameraX CameraView ?
    j
    1 reply · 2 participants
  • n

    Nikola Milovic

    01/11/2020, 4:13 PM
    Hey, I have a login fun and I want it to wait for .signInWithEmail.. to finish and then based on it's result, to do something and return a TaskResult. Now the problem is that the onCompleteListener doesn't happen before the last return. Is there a way to wait for its completion? I looked into .async and .await but didn't find any useful docs. If anyone can point me in the right direction it would be appreciated. (this is in my RemoteDataSource and the Repository calls the Login fun)
    fun Login(email: String, password: String): TaskResult {
             var taskResult = TaskResult.LOADING
    
              firebaseAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener { 
                  if(it.isSuccessful){
                      taskResult = TaskResult.SUCCESS
                  }
              }
    
             return taskResult // THIS TRIGGERS BEFORE THE ONCOMPLETELISTENER, so I always get TaskResult.Loading back
         }
    I am also looking to run this in a coroutine
    r
    a
    4 replies · 3 participants
  • m

    Manuel Lorenzo

    01/12/2020, 5:21 PM
    Any help with the paging library would be very appreciated! https://stackoverflow.com/questions/59706286/android-using-pagedlist-boundarycallback-does-not-retrieve-any-item
    d
    10 replies · 2 participants
  • t

    tseisel

    01/13/2020, 10:37 AM
    Does anyone here have had this problem with
    kapt
    and
    Dagger
    in multi-module projects ?
    > Task :app:kaptDebugKotlin FAILED
    e: error: cannot access HttpClientEngine
      class file for io.ktor.client.engine.HttpClientEngine not found
      Consult the following stack trace for details.
      com.sun.tools.javac.code.Symbol$CompletionFailure: class file for io.ktor.client.engine.HttpClientEngine not found
    It seems to occur because a dependency (Ktor-client in this case) is defined as
    implementation
    in a different Gradle module (feature) than the one the component is created (app).
    a
    1 reply · 2 participants
  • d

    dave08

    01/13/2020, 10:47 AM
    Is it ok to use
    GlobalScope
    for coroutines that need to be tied to the
    Application
    ? There doesn't seem to be a
    lifecycleScope
    for it... or is it better to create a
    CoroutineScope
    and cancel it somewhere in the
    Application
    ?
    i
    m
    3 replies · 3 participants
  • i

    itnoles

    01/13/2020, 10:30 PM
    https://developer.android.com/topic/libraries/view-binding#fragments o.O
    w
    p
    +3
    14 replies · 6 participants
  • s

    Slackbot

    01/14/2020, 8:59 AM
    This message was deleted.
    m
    p
    2 replies · 3 participants
  • m

    Martin Nordholts

    01/14/2020, 1:01 PM
    Hi! A coroutine causes a FATAL EXCEPTION but does not give any stack trace or clue about what coroutine it is:
    01-14 11:40:10.990  4508  4508 E AndroidRuntime: FATAL EXCEPTION: main @coroutine#4
    01-14 11:40:10.990  4508  4508 E AndroidRuntime: Process: com.readly.client, PID: 4508
    I am running with
    System.setProperty(kotlinx.coroutines.DebugKt.DEBUG_PROPERTY_NAME, kotlinx.coroutines.DebugKt.DEBUG_PROPERTY_VALUE_ON)
    but still get the above silent fail. What is the best way to find what coroutine this is? (Without using “brute force”)
    t
    6 replies · 2 participants
  • n

    Nikola Milovic

    01/14/2020, 8:54 PM
    Kinda dumb question, but isn't there an option to make the Edit Text required (must be inputted). I figured it would be available in the layout designer but it's not. I understand that it can be done programmatically but still. This seems like a basic function, I might've missed something, if not is there a feature request or a library or something? Thanks in advance! did google no results related to what i wrote above.
    :google: 4
    z
    c
    +1
    7 replies · 4 participants
  • t

    Tim Malseed

    01/15/2020, 4:13 AM
    Hence the need to import
    androidx.core.graphics.*
    m
    s
    2 replies · 3 participants
  • k

    Kashif

    01/15/2020, 10:15 AM
    Hi I have a webview which loads some url and in url there is Google ReCaptcha added. I See Android device Chrome browser properly loads Recaptcha but my app WebView loads the ReCaptcha and after that it shows “Unable to load ReCaptcha”
    :stackoverflow: 4
    :google: 3
    d
    2 replies · 2 participants
  • k

    Kulwinder Singh

    01/15/2020, 2:14 PM
    hey guys, how can i download
    schema.json
    for github graphql api ? sorry i know its not kotlin related but i have searched a lot on google but not found anything
    :stackoverflow: 4
    :google: 4
    m
    4 replies · 2 participants
  • n

    Nikhil

    01/16/2020, 9:17 AM
    Can I intercept a network requests made by my library in an app level (without adding any code to android library) ? I’m not using okhttp and don’t want to use it.
    t
    z
    7 replies · 3 participants
  • t

    Tolriq

    01/16/2020, 4:16 PM
    @jw Trying to use ViewBinding in my project but while the IDE says everything is OK and show the supposedly generated files, compilation that does not work and the import tells me Unresolved reference: databinding. I can't find any error or logs and only related file is a xxx-binding_classes.json containing
    {
      "mappings": {}
    }
    g
    p
    +1
    15 replies · 4 participants
  • i

    itnoles

    01/17/2020, 2:16 AM
    what is a proper Kotlin way of doing webview in Fragment?
    t
    r
    2 replies · 3 participants
  • j

    Joey

    01/17/2020, 4:35 AM
    What layer should i call my service in an MVP architecture? In the view? presenter? or model?
    t
    12 replies · 2 participants
  • a

    aipok

    01/17/2020, 7:36 AM
    Good morning everyone. Do you use kotlin dsl for gradle already? Is where any usecase, except
    I want to try the new thing
    , why I want to switch to kotlin dsl for build files. I'm asking this, because I'm seeing a bunch of minuses with the IDE support (Android Studio in particular). Will start with pros though... DSL and kotlin build src will give an ability to nicely handle dependencies and it is working like a charm and looks clean etc. With only one minus, that ruins everything. The IDE suggestions for libraries updates are not detected anymore and not possible. Same for
    flavor dimentions
    if they are defined in kotlin object constans, the IDE shows warning, that no dimention are being added to any of the flavors. The build time is also increased for about a minute (with normal 6 minutes build time, it is now about 7 minutes). Does anyone knows what are the plans for support kotlin DSL from the Android Studio side? (just for reference, everything I descibed was tested with latest Android Studio 4.0 canary 😎
    t
    m
    +1
    3 replies · 4 participants
  • c

    Can

    01/17/2020, 9:29 AM
    Good Morning! I am trying to migrate my UI-Tests for Android 10 but my scripts fails, since i can’t grant
    WRITE_EXTERNAL_STORAGE
    on an Android 10 devices - any known workarounds?
    :google: 1
    w
    c
    13 replies · 3 participants
  • b

    Bin

    01/17/2020, 11:14 AM
    fun onShareClick() {
            val intentShareList = ArrayList<Intent>()
            val shareIntent = Intent()
            shareIntent.action = Intent.ACTION_SEND
            shareIntent.type = "text/plain"
            val resolveInfoList = packageManager.queryIntentActivities(shareIntent, 0)
            for (resInfo in resolveInfoList) {
                val packageName = resInfo.activityInfo.packageName
                val name = resInfo.activityInfo.name
                if (packageName.contains("com.facebook") ||
                    packageName.contains("com.twitter.android") ||
                    packageName.contains("<http://com.google.android.gm|com.google.android.gm>") ||
                    packageName.contains("com.android.mms") ||
                    packageName.contains("com.whatsapp")
                ) {
                    val intent = Intent()
                    intent.component = ComponentName(packageName, name)
                    intent.action = Intent.ACTION_SEND
                    intent.type = "text/plain"
                    intent.putExtra(Intent.EXTRA_SUBJECT, "Your Subject")
                    intent.putExtra(Intent.EXTRA_TEXT, "Your Content")
                    intentShareList.add(intent)
                }
            }
            if (intentShareList.isEmpty()) {
                Toast.makeText(this@MainActivity, "No apps to share !", Toast.LENGTH_SHORT).show()
            } else {
                val chooserIntent = Intent.createChooser(intentShareList.removeAt(0), "Share via")
                chooserIntent.putExtra(
                    Intent.EXTRA_INITIAL_INTENTS,
                    intentShareList.toTypedArray()
                )
                startActivity(chooserIntent)
            }
        }
    }
    d
    2 replies · 2 participants
  • t

    Thomas Nordmeyer

    01/17/2020, 11:19 AM
    Hi all, do you have any recommendation how to handle authentication loss in background (e.g. when receiving an 401 from a call in background). I am tending to invalidate the authentication in my repository, make my view models listen to the change and navigate to the login screen. But I am in doubt if I should observe repository members at all? Does anybody have a rough hint on how to do this with AAC?
    w
    b
    13 replies · 3 participants
  • i

    iex

    01/17/2020, 5:26 PM
    How do I force Gson lib to parse this simply to a string primitive?
    JsonParser().parse("2020-01-17T18:21:15+0100")
    o
    j
    5 replies · 3 participants
  • g

    Gunis

    01/18/2020, 12:54 PM
    How can i get the indices of items in a list that match a condition?
    t
    a
    3 replies · 3 participants
  • d

    David Martin

    01/18/2020, 2:15 PM
    Hi guys, have you ever faced this problem before? I've got this error as the attached image, the red rectangle is the file under generated folder, the blue rectangle is my strings file. I don't understand why Android Studio(AS) autogenerate a "google_api_key" even when I deleted my own key then rebuild the project. But if I re-add my own key then AS throw an error as you can see. Thanks in advance about your help.
    :google: 1
    :stackoverflow: 4
    r
    a
    5 replies · 3 participants
Powered by Linen
Title
d

David Martin

01/18/2020, 2:15 PM
Hi guys, have you ever faced this problem before? I've got this error as the attached image, the red rectangle is the file under generated folder, the blue rectangle is my strings file. I don't understand why Android Studio(AS) autogenerate a "google_api_key" even when I deleted my own key then rebuild the project. But if I re-add my own key then AS throw an error as you can see. Thanks in advance about your help.
:google: 1
:stackoverflow: 4
Even when I create new project and create new strings file then this error rise again.
r

rkeazor

01/19/2020, 1:57 AM
Try stackoverflow. this workspace is more for Kotlin related questions
a

Andrew

01/19/2020, 2:51 AM
All the string resources should go in strings.xml, since you have some defined in values.xml the build process is auto-merging them with the strings.xml file.
Also for constants like api keys you should be doing something like this. https://richardroseblog.wordpress.com/2016/05/29/hiding-secret-api-keys-from-git/
d

David Martin

01/19/2020, 12:33 PM
@Andrew No, the values is auto-generated file, I don't have any values file.
View count: 3