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

    Alexanderkvamme

    03/19/2020, 8:34 AM
    Anyone know if android studio has a shortcut to toggle the debug area (bottom part of the creen)? In xcode
    cmd+y
    did this, but i cant seem to find an equivalent.
    w
    k
    • 3
    • 5
  • r

    rattleshirt

    03/19/2020, 4:16 PM
    Anyone familiar with the
    compileDebugAndroidTestKotlin
    task having compilation error with
    Unresolved reference: id
    when using it in androidTest
    withId(R.id..)
    ?
    • 1
    • 1
  • m

    Marc Knaup

    03/20/2020, 10:49 AM
    Is there an open source Android app project that’s well-written in Kotlin and well-structured? I’m looking for a good example project to send to a development team and say “that’s the type of structure and quality we’re aiming for”.
    a
    a
    • 3
    • 4
  • s

    Shreyas Patil

    03/20/2020, 1:13 PM
    🍲 Foodium is a sample food blog Android application 📱 built to demonstrate use of Modern Android development tools Built with : Kotlin, Coroutines, Flow, Dagger 2, Architecture Components, MVVM, Room, Retrofit, Moshi, Material Components and other Jetpack libraries. Link - https://github.com/PatilShreyas/Foodium
    👍 1
    j
    • 2
    • 1
  • g

    Galou Minisini

    03/20/2020, 3:21 PM
    If you are a junior developer looking for some tips on how to apply and get your dream job I wrote a series of article on Medium to help you. (I'm looking for feedback from developer with some exeperience as well). Here's the link to the first part https://proandroiddev.com/nailing-your-first-job-as-an-android-developer-part-1-build-your-portfolio-15f9d532def1
    👍 2
    k
    • 2
    • 4
  • b

    Bruno_

    03/21/2020, 10:58 AM
    how do you approach updating the view model during long running tasks? I have to crawl data from ~20 websites and display it as a list. Do I: • make an
    update publisher
    (new items are being pushed into it) • refresh the view model data every let's say 1s • try to implement it so that if the user get's to the end of the list, more items are loaded
    :stackoverflow: 4
    :google: 2
    a
    k
    • 3
    • 4
  • s

    Slackbot

    03/21/2020, 4:56 PM
    This message was deleted.
    :stackoverflow: 1
    n
    a
    • 3
    • 2
  • s

    Slackbot

    03/22/2020, 1:35 PM
    This message was deleted.
    t
    • 2
    • 2
  • s

    Sourabh Rawat

    03/22/2020, 3:55 PM
    android 11 emulator returns empty
    Cursor
    when trying to get audio files from
    MediaStore
    . ANy help?
    :stackoverflow: 1
    v
    t
    • 3
    • 5
  • j

    Joshua

    03/22/2020, 3:56 PM
    I'm trying to do the following:
    app:logo="@{viewModel.toolbarViewConfig.isMenuVisible}"
    but I get the error
    Cannot find a setter for <androidx.appcompat.widget.Toolbar app:logo> that accepts parameter type androidx.lifecycle.MutableLiveData<java.lang.String>
    
    If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
    I somehow want to set the app:logo to empty. I tried it here:
    viewModel.toolbarViewConfig.isMenuVisible.value = ""
    v
    • 2
    • 1
  • a

    Arslan Mushtaq

    03/23/2020, 8:26 AM
    I’m building a counter app with MVP design pattern in Android Studio. I want to hide my reset button when the value of the counter is 0 so where should I put my code for controlling it’s visibility? I have the following classes: • MainActivity.kt (Class) • MainActivityPresenter.kt (Class) • MainActivityModel (Class) • ContractInterface.kt (Interfaces)
    :google: 1
    f
    k
    • 3
    • 2
  • e

    Eslam Hussein

    03/23/2020, 12:00 PM
    https://stackoverflow.com/questions/60812900/how-to-integrate-lottie-library-with-android-project-that-doesnt-support-androi
    a
    • 2
    • 4
  • e

    Ellen Spertus

    03/23/2020, 8:56 PM
    I’m having trouble mocking
    ActivityInfo.exported
    with Mockito. Here’s the relevant part of my code:
    private fun makeResolveInfo(appName: String, packageName: String, exported: Boolean = true) : ResolveInfo {
        val activityInfo = mock(ActivityInfo::class.java)
        `when`(activityInfo.exported).thenReturn(exported)
        // code omitted
    }
    The error is:
    org.mockito.exceptions.misusing.MissingMethodInvocationException: 
    when() requires an argument which has to be 'a method call on a mock'.
    For example:
        when(mock.getArticles()).thenReturn(articles);
    
    Also, this error might show up because:
    1. you stub either of: final/private/equals()/hashCode() methods.
       Those methods *cannot* be stubbed/verified.
       Mocking methods declared on non-public parent classes is not supported.
    2. inside when() you don't call method on mock but on some other object.
    Here is the javadoc for the
    exported
    getter (which is in
    ComponentInfo
    , which
    ActivityInfo
    extends): https://developer.android.com/reference/android/content/pm/ComponentInfo#exported
    m
    • 2
    • 10
  • r

    riflockle

    03/24/2020, 6:11 AM
    Hello I want to see coroutine all `dispatcher`’s call stack. I wrote
    android test
    source code 
    // AnyTest.kt
    
    @Test
    fun callStackCrop_a() = runBlocking {
      a(0)
      a(1)
      a(2)
      a(3)
      a(10)
      ***a(11)***   // 76 line
      a(12)
    }
    
    suspend fun a(x: Int): Unit = b(x)   // this action cropped....
    suspend fun b(x: Int) = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
      c(x)      // 82 line
    }
    suspend fun c(x: Int) {
      if (x > 10) {
        throw NullPointerException("ops x = ${x} > 0")   // 86 line
      }
    }
    Test result is that
    at ___.AnyTest.c(AnyTest.kt:86)
    	at ___.AnyTest$b$2.invokeSuspend(AnyTest.kt:82)
    	at |b|b|b(Coroutine boundary.|b(|b)
    	at ___.AnyTest$koroChase$1.invokeSuspend(AnyTest.kt:76)
    Caused by: java.lang.NullPointerException: ops x = 11 > 0
    	at ___.AnyTest.c(AnyTest.kt:86)
    	at ___.AnyTest$b$2.invokeSuspend(AnyTest.kt:82)
    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
    "Calling
    b() method
    at
    a()
    " is removed….. I want to see
    all call stack trace
    in coroutine how to recover this call stack.....? Attach a link with a similar problem https://github.com/Kotlin/kotlinx.coroutines/issues/1660
    z
    • 2
    • 2
  • i

    iex

    03/24/2020, 1:54 PM
    Hi! I wrote this extension to be able to handle back button event in fragments:
    fun Fragment.onBack(consume: Boolean = false, callback: () -> Unit) {
        activity?.onBackPressedDispatcher?.addCallback {
            callback()
            if (!consume) {
                findNavController().navigateUp()
            }
        }
    }
    Works perfectly when I don't want to consume the event. It also works when I consume it, except that after it the back button is dead. How do I consume only the current back press?
    a
    • 2
    • 9
  • t

    Travis Griggs

    03/24/2020, 5:55 PM
    I’m trying to get
    assert()
    to do something meaningful. I note that I’m supposed to run the JVM with
    -ea
    (as per https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/assert.html). But where do I actually do that at?
    j
    s
    t
    • 4
    • 14
  • g

    Galou Minisini

    03/24/2020, 8:20 PM
    Looking for books recommendations for an intermediate android dev. Or courses to improve my skills. Anyone?
    a
    k
    +2
    • 5
    • 5
  • o

    Ofir Bar

    03/24/2020, 10:17 PM
    I know it sounds stupid, but following are 2 scenarios. I wonder why the compiler complain about 1) but on 2) there is nothing? Obviously on 2), T can't be null
    c
    • 2
    • 2
  • c

    Colton Idle

    03/24/2020, 10:32 PM
    Does anyone know if it's possibly to write a lint check that just warns if there's a specific import being used?
    b
    l
    • 3
    • 9
  • u

    182630g

    03/25/2020, 2:42 AM
    hi just a quick question , where are Obervables usually put in a kotlin android app ?
    o
    k
    • 3
    • 3
  • j

    jaran

    03/25/2020, 8:17 AM
    Having issues upgrading Kotlin plugin to 1.3.71 in Android Studio 3.6.1. Says to check logs, but the log says very little. This is the only thing showing up in the log during the installation. Is the last warning a pointer that makes sense to anyone?
    2020-03-25 09:16:27,867 [566297214]   WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: language for id: preferences.language.Kotlin.scripting 
    2020-03-25 09:16:27,870 [566297217]   WARN - ConfigurableExtensionPointUtil - use other group instead of unexpected one: project.propCompiler 
    2020-03-25 09:16:28,095 [566297442]   INFO - j.ide.plugins.RepositoryHelper - using cached plugin list (updated at 25/03/2020, 09:10) 
    2020-03-25 09:16:28,306 [566297653]   WARN - llij.ide.plugins.PluginManager - 4.0 not loaded: since build 193.5233.102 > AI-192.7142.36.36.6241897
    i
    a
    • 3
    • 4
  • a

    antoniomarin

    03/25/2020, 10:21 AM
    Heya, one Android specific question. Is there any way to manually tigger
    onConfigurationChanged
    ? I’m dealing with the locales, and when I do update it manually I need to somehow
    recreate
    the views, recreating activity will kick user out and he will need to re-log so I would rather try to avoid that. I’m also trying with the following but it doesn’t work completely which is weird in fairness:
    val res = resources
    val configuration = res.configuration
    configuration.setLocale(Locale(preferences.userLocale))
    onConfigurationChanged(configuration)
    w
    • 2
    • 5
  • m

    Mark

    03/25/2020, 12:08 PM
    In a RecyclerView adapter, I have
    init {
        someInstance.someVal = { someHelper.someFun(it) }
    }
    and LeakCanary hinted that this was causing a leak, so (as a complete stab in the dark) I switched to using a method reference and the leak seemed to go away. Can anyone explain why such a seemingly minor change could fix a leak, please?
    init {
        someInstance.someVal = someHelper::someFun
    }
    ☝️🏻 1
    m
    z
    • 3
    • 4
  • o

    Olle

    03/25/2020, 2:17 PM
    Hey, so im converting an internal Java library to Kotlin and keep running into
    class file for kotlin.jvm.internal.markers.KMappedMarker not found
    whenever im compiling the project implementing the library. I’ve added the kotlin stdlib to the library as a dependecy like so:
    api("org.jetbrains.kotlin:kotlin-stdlib:1.3.71")
    It does compile if i add kotlin to the project implementing the library but we would like to avoid that if possible. any tips/pointers would be appriciated, Thanks!
    • 1
    • 1
  • c

    Cody Engel

    03/25/2020, 5:32 PM
    Has anyone ran into issues with a viewmodel directly invoking a navcontroller? The handoff for navigation between a fragment and viewmodel is not at all elegant so I'm thinking about just injecting the navcontroller into the viewmodel but I'm having a hard time finding references that support that idea
    t
    s
    o
    • 4
    • 12
  • s

    Sagar Suri

    03/26/2020, 1:57 AM
    https://twitter.com/sagarsuri94/status/1242981747643445253?s=21
    • 1
    • 1
  • c

    Chung

    03/26/2020, 1:57 AM
    I am learning sunflower app and came across this
    tabFragmentsCreators
    variable https://github.com/android/sunflower/blob/master/app/src/main/java/com/google/samples/apps/sunflower/adapters/SunflowerPagerAdapter.kt#L32 What is the benefit of using a
    Map<Int, () -> Fragment>
    instead of just
    Map<Int, Fragment>
    a
    d
    • 3
    • 6
  • b

    Benyam Seifu

    03/26/2020, 6:01 AM
    Can I create Flipboard's flipping animation using the new MotionLayout?
    t
    • 2
    • 2
  • a

    adeyds

    03/26/2020, 7:57 AM
    helooo, how to access layout (a_layout.xml) in module (common module) from other module (feature module) was include in b_layout.xml ? any idea? im trying with kotlin synthetic but error :
    unresolved reference
    a
    a
    m
    • 4
    • 4
  • e

    Ellen Spertus

    03/26/2020, 6:49 PM
    Can anyone point me to an example of mocking Android components with MockK? I’ve asked on #mockk but gotten no responses.
    t
    • 2
    • 1
Powered by Linen
Title
e

Ellen Spertus

03/26/2020, 6:49 PM
Can anyone point me to an example of mocking Android components with MockK? I’ve asked on #mockk but gotten no responses.
t

tseisel

03/27/2020, 8:23 AM
You may only be able to mockk interfaces such as
SharedPreferences
. I think it would be easier to use Robolectric Shadows.
View count: 2