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

    Jordan Dixon

    08/16/2019, 1:20 PM
    So i'm having this weird issue - I'm manually building a data model for my app layer and then using KotlinPoet to generate a Room compliant version of the same model that I'm using as a Room entity. When I clean and build, Room can't find the generated model. The only path where Room can find the generated model is if I clean -> build -> change the order of my gradle dependencies -> re-sync -> build. In the last build, Room will find the generated models. Anyone have any idea why?
    m
    w
    e
    • 4
    • 9
  • p

    Paul Dhaliwal

    08/16/2019, 3:04 PM
    I have a custom view that animates when clicked for which I’m trying to improve performance. When I enable Show GPU view updates in developer settings I notice that while this view is animating the entire screen flashes the whole time it is animating. There is also an animated vector drawable inside the same FrameLayout as this custom view and while the AVD is animating the entire screen flashes as well. Is this a good indicator of where the performance issues may come from? If so how could I solve this? Alternatively I have the same custom view in another layout which has no performance issues and I notice that while this view is animating, at first the whole screen flashes however for the last half of the animation only the custom view flashes. Thanks!
    :google: 2
    :stackoverflow: 1
    • 1
    • 1
  • s

    Shalom Halbert

    08/16/2019, 3:27 PM
    I've taken LiveData and databinding Observables for granted. Someone asked why I don't unsubscribe from Observing either, and I realized that I don't know. Tried finding an answer, but haven't found one. In our project, Observables and LiveData are used for databinding and observed from Fragments/Activities. Would love to know if I have implemented them wrong, or learn why unsubscribing isn't necessary.
    v
    m
    • 3
    • 3
  • j

    Jonny

    08/17/2019, 5:06 PM
    I see that I'm getting camelCase naming from the array response in getJobs, so I'm thinking now that the parsing is simply case sensitive?
    l
    • 2
    • 5
  • f

    fal

    08/17/2019, 6:53 PM
    Am I the only soul on earth that finds the whole LiveData encapsulation atrocious to the eyes? I obviously understand why we only let 'LiveData' vars accessible and not mutable ones, but it honestly kills me inside to have repeated fields where one has prefixed '_', e.g.:
    private val _navigateToSpeakerAction = MutableLiveData<Event<SpeakerId>>()
    val navigateToSpeakerAction: LiveData<Event<SpeakerId>> = _navigateToSpeakerAction
    it's so goddamn ugly.. i think i even prefer just a standalone getter
    m
    p
    +2
    • 5
    • 32
  • z

    zokipirlo

    08/19/2019, 8:10 AM
    Is OkBuck ready for use with Kotlin (coroutines, channels,...) and Android? Or is Gradle still preferred?
    g
    • 2
    • 3
  • p

    paras

    08/19/2019, 11:30 AM
    I am facing one issue using dagger2 + Kotlin This is my ModuleClass
    object AppModule {
    
        @JvmStatic
        @Provides
        fun provideRequestOptions() = RequestOptions.placeholderOf(R.drawable.white_background)
                .error(R.drawable.white_background)
    
        @JvmStatic
        @Provides
        fun provideGlideInstance(application: Application, requestOptions: RequestOptions) =
                Glide.with(application).setDefaultRequestOptions(requestOptions)
    
        @JvmStatic
        @Provides
        fun provideAppDrawable(application: Application) =
                ContextCompat.getDrawable(application, R.drawable.logo)
    }
    In my Activity I am using 2 injects
    @Inject
        lateinit var drawableLogo: Drawable
    
        @Inject
        lateinit var requestManager: RequestManager
    
        fun setLogo() = requestManager.load(drawableLogo).into(loginLogo)
    I am getting below error:-
    /app/build/tmp/kapt3/stubs/debug/com/example/di/AppComponent.java:7: error: [Dagger/Nullable] android.graphics.drawable.Drawable is not nullable, but is being provided by @org.jetbrains.annotations.Nullable @Provides android.graphics.drawable.Drawable com.example.di.AppModule.provideAppDrawable(android.app.Application)
    public abstract interface AppComponent extends dagger.android.AndroidInjector<com.example.BaseApplication> {
                    ^
          android.graphics.drawable.Drawable is injected at
              com.example.AuthActivity.drawableLogo
          com.example.AuthActivity is injected at
              dagger.android.AndroidInjector.inject(T) [com.example.di.AppComponent → com.example.di.ActivityBuildersModule_ContributeAuthActivity$app_debug.AuthActivitySubcomponent]
    
    FAILURE: Build failed with an exception.
    I think this issue is somehow related to
    @Nullable
    annotation used by the IDE but I am not sure about the exact issue, can somebody explain about this issue?
    :stackoverflow: 2
    d
    m
    k
    • 4
    • 4
  • m

    morozov

    08/19/2019, 3:14 PM
    any ideas someone?) or unclear?)
    l
    • 2
    • 14
  • c

    cucharro

    08/19/2019, 3:27 PM
    Hello everybody. I'm in a weird case. I'm trying to debug some code but my debugger never stops at finally blocks, does anyone knows why? To me the finally block should be reached all the time, right?
    r
    k
    l
    • 4
    • 35
  • s

    Sergio C.

    08/19/2019, 10:17 PM
    Hello people. Is there any performance advantage about using retrofit with the suspend modifier to use them in coroutines? It's the version starting at 2.6.0. Which thread will retrofit use in this case? How is this working behind the scenes? Using coroutine thread or some other retrofit thread? The coroutine threads are supposed be "cheaper" and I need to make upto some hundred requests simultaneuously.
    j
    • 2
    • 7
  • m

    morozov

    08/20/2019, 8:09 AM
    Any ideas guys?)
    :stackoverflow: 1
    e
    • 2
    • 9
  • r

    ribesg

    08/20/2019, 9:37 AM
    Use #splitties
    ➕ 1
    g
    l
    • 3
    • 8
  • s

    Sergey

    08/20/2019, 2:23 PM
    Do you have any idea @Kris Wong?
    k
    j
    +7
    • 10
    • 19
  • r

    ritesh

    08/21/2019, 12:14 PM
    Wondering if the order of interceptors plays a role in retrofit?
    :stackoverflow: 1
    :google: 1
    l
    • 2
    • 4
  • d

    dewildte

    08/21/2019, 7:22 PM
    Did Android Studio 3.5 remove “Use same device for future launches” ???!!!?!
    b
    r
    +3
    • 6
    • 20
  • p

    Pranjal Desai

    08/21/2019, 11:52 PM
    Hello, does anyone know how to use Exoplayer with TextureView. I'm trying to make it Fullscreen. I don't have a lot of experience with TextureView
    g
    r
    • 3
    • 2
  • e

    Eric Martori

    08/22/2019, 3:43 PM
    In your opinion what is the best library for loading images to use with kotlin?
    g
    c
    +3
    • 6
    • 11
  • b

    Bilagi

    08/22/2019, 4:42 PM
    Has any one faced
    Fatal Exception: java.lang.IllegalStateException: Already in the pool!
    crash
    Fatal Exception: java.lang.IllegalStateException: Already in the pool!
           at androidx.core.util.Pools$SimplePool.release + 117(Pools.java:117)
           at androidx.recyclerview.widget.AdapterHelper.recycleUpdateOp + 743(AdapterHelper.java:743)
           at androidx.recyclerview.widget.AdapterHelper.recycleUpdateOpsAndClearList + 750(AdapterHelper.java:750)
           at androidx.recyclerview.widget.AdapterHelper.consumePostponedUpdates + 123(AdapterHelper.java:123)
           at androidx.recyclerview.widget.AdapterHelper.consumeUpdatesInOnePass + 557(AdapterHelper.java:557)
           at androidx.recyclerview.widget.RecyclerView.processAdapterUpdatesAndSetAnimationFlags + 3701(RecyclerView.java:3701)
           at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1 + 3945(RecyclerView.java:3945)
           at androidx.recyclerview.widget.RecyclerView.dispatchLayout + 3755(RecyclerView.java:3755)
           at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations + 1888(RecyclerView.java:1888)
           at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run + 5163(RecyclerView.java:5163)
           at android.view.Choreographer$CallbackRecord.run + 916(Choreographer.java:916)
           at android.view.Choreographer.doCallbacks + 718(Choreographer.java:718)
           at android.view.Choreographer.doFrame + 647(Choreographer.java:647)
           at android.view.Choreographer$FrameDisplayEventReceiver.run + 902(Choreographer.java:902)
           at android.os.Handler.handleCallback + 836(Handler.java:836)
           at android.os.Handler.dispatchMessage + 103(Handler.java:103)
           at android.os.Looper.loop + 232(Looper.java:232)
           at android.app.ActivityThread.main + 6802(ActivityThread.java:6802)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1103(ZygoteInit.java:1103)
           at com.android.internal.os.ZygoteInit.main + 964(ZygoteInit.java:964)
    I am facing this weird crash on production. Can any one please help
    j
    r
    • 3
    • 5
  • k

    koufa

    08/22/2019, 5:21 PM
    Hey, now that Retrofit since 2.6 supports
    suspend
    using behind the scenes
    Call
    interface and then enqueuing it do we need to wrap a retrofit call with a
    withContext
    IO
    scheduler ? As actually the
    enqueue
    will already do the call asynchronously and we are safe with calling it on the Android mainthread
    d
    j
    • 3
    • 4
  • k

    Kulwinder Singh

    08/23/2019, 8:15 AM
    Why i'm getting
    Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
    while using
    viewModel()
    function to get fragment's viewmodel ?
    Untitled
    l
    m
    +2
    • 5
    • 6
  • l

    louiscad

    08/23/2019, 9:38 AM
    Here's a random dream: Android resources ids (
    R.sometype.stuff
    ) generated as inline classes.
    🙏 1
    t
    m
    a
    • 4
    • 8
  • d

    dave

    08/23/2019, 9:44 AM
    Hello guys. We are new to AAC. We are wondering how we should or where we should keep the state of our Auth. At first glance we thought of having a central AuthViewModel, but we have few activities and the view model couldn't be share as far as I know. Now we are thinking on keeping the state in the AuthRepository. Could anyone share experiences on it? Regards!
    a
    i
    • 3
    • 7
  • l

    leodeleon

    08/23/2019, 11:04 AM
    :thread-please: 1
    v
    • 2
    • 12
  • m

    Marc Knaup

    08/23/2019, 7:28 PM
    Is this a Kotlin or an R8 bug?
    java.lang.LinkageError: Method void g.y4$b.a() [aka
    app.SomeFragment.Model.clear()
    ] overrides final method in class Lf/n/j0 [aka
    androidx.lifecycle.ViewModel
    ];
    The method in question is
    fun clear()
    in my own
    ViewModel
    subclasses.
    clear()
    in Android’s
    ViewModel
    is
    final
    with package-visibility so the
    clear()
    of my own subclass should be treated as a completely different function!
    • 1
    • 1
  • e

    Eric Martori

    08/23/2019, 9:05 PM
    I don't know if this is the correct channel for this question, so forgive me if it is not the correct place. I want to add dependency:
    androidx.lifecycle:lifecycle-runtime-ktx:$androidLifecycle
    in a library project If I add this dependency in an Android library project there is no problem, but if I add this dependency in a normal kotlin library the extension functions cannot be found. This import statement stops working:
    import androidx.lifecycle.lifecycleScope
    But this doesn't:
    import androidx.lifecycle.LifecycleOwner
    I am creating a library that have a dependency on the androidx lifecycle but I don't need resources or access to any normal
    android.*
    dependency, that's why I'm trying to use a normal kotlin library instead of an android library Any idea on why this is happening?
    v
    • 2
    • 2
  • t

    tateisu

    08/24/2019, 9:02 AM
    // (A) no warning
    if(Build.VERSION.SDK_INT >= 26 ) {
    	// using API 26+
    }else if(Build.VERSION.SDK_INT >=22) {
    	// using API 22+
    }else{
    	// using old API
    }
    
    // (B) waring raised.
    // "Call required API level 26 (current min is 21): ..."
    when{
    	Build.VERSION.SDK_INT >= 26 ->{
    		// using API 26+
    	}
    	Build.VERSION.SDK_INT >=22 ->{
    		// using API 22+
    	}
    	else->{
    		// using old API
    	}
    }
    how to avoid warnings without extra if(Build.VERSION.SDK_INT >= ... ?
    :stackoverflow: 1
    🤔 1
    • 1
    • 1
  • k

    Kulwinder Singh

    08/24/2019, 9:05 AM
    Hi, what do you guys use for LiveData single(one time) Events, previously i was using
    SingleLiveEvent
    but previously i had seen some type of
    Event
    (don't know exactly what it was called) class. i have seen that class somewhere in google architecture samples or in I/O talk but now i'm unable to find that, can you guys please let me know if
    SingleLiveEvent
    is best for one time event or is android team provided some other solutions ?
    d
    r
    +6
    • 9
    • 98
  • j

    Joan Colmenero

    08/25/2019, 10:29 AM
    Hi! I'm planning to move
    MVP
    apps to
    MVVM
    (Or even create a new ones with that architecture), so I'd like to know if there's any reference
    github
    repo that you are looking and recommend to me, that which contains
    Clean Architecture
    with
    Kotlin
    as :
    Navigation
    ,
    Coroutines
    ,
    Multi-module
    ,
    Dagger2/Koin/Kodein
    ,
    ViewModel
    ,
    LiveData
    , etc...? I'd love to learn this to increase my knowledge doing clean apps. Thank you guys 😄
    a
    k
    • 3
    • 3
  • g

    Gunslingor

    08/25/2019, 5:30 PM
    if your making something like an RSS reader and the user clicks to be taken to a rss link site like BBC or whatever, is it okay to do that with a webview or is a custom chrome tab the way to go (and how compatible is that feature with older apis)? Some of these sites seem to be opening the browser instead of populating the webview which shouldn't be happening. I do need to put controls to my site on top of each site visited.
    a
    • 2
    • 7
  • j

    jermainedilao

    08/26/2019, 2:25 AM
    Hi! Im doing Clean Architecture pattern in my app. Let’s say I have a
    Product
    item. Now, that
    Product
    must contain
    category
    and
    subcategory
    . Currently, the API only returns the
    guid
    of the category and subcategory. Now the question is. Should the mapping of getting the
    category
    and
    subcategory
    from the API and putting them inside the
    Product
    class be inside the
    data
    module? OR I can put it inside my
    GetProductUseCase
    ? If I choose the latter. So my usecase would look something like this:
    getProducts()
        .zip(repo.getCategory(), repo.getSubCategory())
        .flatMap { 
            product.category = category
            product.subcategory = subcategory
         }
    What’s the best practice for this?
    w
    • 2
    • 2
Powered by Linen
Title
j

jermainedilao

08/26/2019, 2:25 AM
Hi! Im doing Clean Architecture pattern in my app. Let’s say I have a
Product
item. Now, that
Product
must contain
category
and
subcategory
. Currently, the API only returns the
guid
of the category and subcategory. Now the question is. Should the mapping of getting the
category
and
subcategory
from the API and putting them inside the
Product
class be inside the
data
module? OR I can put it inside my
GetProductUseCase
? If I choose the latter. So my usecase would look something like this:
getProducts()
    .zip(repo.getCategory(), repo.getSubCategory())
    .flatMap { 
        product.category = category
        product.subcategory = subcategory
     }
What’s the best practice for this?
w

wasyl

08/26/2019, 7:08 AM
I’d say
data
module. My reasoning is that this is a shortcoming of the API, and ideally API would return product, category and subcategory in one call. Once the API is fixed you shouldn’t have to modify your use case to adjust to the new data layer behavior. Conversely if it was business requirement that category and subcategory must be fetched separately (e.g. because they change more often than the Product), or it was an application requirement (we need product very early and categories later on) only then I would move fetching them to some use case.
👍 1
💯 2
j

jermainedilao

08/26/2019, 10:56 AM
@wasyl Great insight. Thanks for the input! 💯 Appreciated.
View count: 1