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

    Saket Poddar

    03/12/2020, 9:40 AM
    There is scenario, in my staging app where I need to change my base url provided by user. But issue is I have injected retrofit object using dagger(Using @Provides annotation). Now is it right to re inject my DaggerAppComponent or how should I have been proceeded.
    s
    • 2
    • 4
  • m

    mike.dev

    03/12/2020, 3:47 PM
    Hi guys. I am not sure here is the right channel to ask, but could you help a question. After update to use Android Gradle Plugin 3.6.1, our unit test keeps getting
    OutOfMemoryError
    exception.  It happens on the building phrase with this task
    generateDebugUnitTestStubRFile"
    We have multiple modules, and OOM error occurs randomly I can fix the issue by increasing the gradle max-heap size, but it’s not a good option because we ’re very close to the limit of the hardware.  So far, what I have tried are: 1. Update Gradle to 6.2.2 2. Tried to turn on/off grade worker API with `kapt.use.worker.api`&
    android.enableGradleWorkers
    flags (they are off by now) 3. Play around with some testOptions flags (https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html), for example forkEvery, maxParallelForks. But I am not sure it would help, because the failure happens on the building phrase. Here is the crash log:
    Caused by: com.android.ide.common.workers.WorkerExecutorException: 1 exception was raised by workers:
     java.lang.OutOfMemoryError: GC overhead limit exceeded
       at com.android.ide.common.workers.ExecutorServiceAdapter.await(ExecutorServiceAdapter.kt:108)
       at com.android.ide.common.workers.ExecutorServiceAdapter.close(ExecutorServiceAdapter.kt:118)
       at <http://kotlin.io|kotlin.io>.CloseableKt.closeFinally(Closeable.kt:53)
    The crash happened by this line of code.  https://android.googlesource.com/platform/tools/base/+/studio-master-dev/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/res/GenerateLibraryRFileTask.kt#120 It will be very appreciated if anyone of you would suggest any solution or direction to investigate. Generate a heapdump is on my plan
    a
    • 2
    • 2
  • a

    arekolek

    03/12/2020, 4:30 PM
    I enabled the
    viewBinding
    in Android Studio 3.6.1, with Gradle 6.2.2, Android Gradle plugin 3.6.1 and Kotlin Gradle plugin 1.3.70. This code:
    val binding = SomeLayoutBinding.bind(itemView)
    produces this warning in the IDE:
    Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
    Even though, when I open the generated
    SomeLayoutBinding.java
    file, I see that it's annotated with `@NonNull`:
    @NonNull
      public static SomeLayoutBinding bind(@NonNull View rootView) {
    Am I missing something here? Anybody else has this issue? Where would I even report it?
    m
    • 2
    • 2
  • k

    Kulwinder Singh

    03/13/2020, 5:54 AM
    Map<String,Any> vs Map<,
    val data: MutableMap<String, Any>
    /..../
    val client = data.get("MY_DATA") as Map<String, Any>//Unchecked cast: Any? to Map<String, Any>
    android studio suggest to convert it to
    val client = data.get("MY_DATA") as *Map<*, *>*
    What is difference between both?
    r
    • 2
    • 1
  • c

    Colton Idle

    03/13/2020, 9:43 AM
    Typing Kotlin code in Android Studio is too slow. Please consider voting for this issue to draw more attention to the problem. https://youtrack.jetbrains.com/issue/KT-32158
    👍 5
    t
    a
    • 3
    • 6
  • j

    James K Williams

    03/13/2020, 10:56 AM
    Hey everyone! I've heard that some of Android developers use IDEA instead of Android Studio. Is there any reason to do so?
    😮 1
    w
    a
    +3
    • 6
    • 5
  • b

    Bruno_

    03/14/2020, 12:33 PM
    can I create ViewModel instances myself or do I have to do it with
    by viewModels()
    ? tried to google
    creating view model manually
    and
    kotlin by viewModels()
    , couldn't find anything interesting
    k
    • 2
    • 5
  • j

    Joshua

    03/14/2020, 3:57 PM
    I'm using
    setHomeAsUpIndicator
    to display a drawer icon which is placed by default on the left side. Which function can I use to an icon on the right side of the toolbar?
    a
    • 2
    • 1
  • j

    Jonny

    03/14/2020, 9:48 PM
    I'm having a problem where when I have navigated according to the actions selected in the images below, and then click the android back button from the findJobsFragment, the app goes to the background as expected. However when I open the app again, I am returned to the homeFragment instead of the findJobsFragment. How can I get the expected behavior? https://imgur.com/DWf20LU https://imgur.com/2BKGHtn
    v
    • 2
    • 2
  • c

    Colton Idle

    03/15/2020, 2:00 AM
    Does anyone have any tips on getting consistency between code style for developers? It seems like IntelliJ codestyle is a little different between intellij/kotlin style, and then there's also https://developer.android.com/kotlin/style-guide. Seems like a lot of options, but I'm looking for something turnkey that works in static code analysis and works easily to import into intellij so the IDE formatting matches the actually analyzer. Not the biggest nitpicker on style, and using something out of the box from square or another trusted company would be cool. Curious to hear what everyone is using!
    n
    v
    • 3
    • 9
  • s

    Shreyas Patil

    03/15/2020, 8:56 AM
    Just published an article “🔪Introduction to #Dagger DI 💉 by a Life way!”. #DI is well explained with a simple Life ❤️ example. It'll help you in understanding concept and to start with it😉. Link: https://link.medium.com/eH7FMnO0R4 #kotlin #androiddev #androiddevelopment #java #android #dagger2 #square #google #inject
    s
    • 2
    • 1
  • j

    jeff

    03/15/2020, 10:15 PM
    Is there a standard/recommended way that I can write, for example,
    Observable.zip(obsA, obsB) { a, b -> a + b }
    instead of
    Observable.zip(
            obsA,
            obsB,
            BiFunction { a, b -> a + b }
    )
    ? I know how to write
    SomethingCustom.zip(obsA, obsB) { a, b -> a + b }
    but I'm asking if there's a best practice or well-known library or something
    f
    • 2
    • 2
  • j

    Joey

    03/15/2020, 10:54 PM
    Hi i am new in mobile development. I would like to ask if there is something like .env in android development? Thanks
    m
    a
    +2
    • 5
    • 8
  • a

    Almas Shagdarov

    03/16/2020, 7:41 AM
    Hi everyone. I have question i need to 3 screens they are same but content is different by content i mean i m same request but query of request depends on status that i give. So my question i wanna call one fragment but with different args problem is how can i call one viewmodel to every instance of fragment?
    z
    • 2
    • 1
  • v

    vs.thaakur

    03/16/2020, 8:44 AM
    Hi everyone I am creating a custom BottomBar by extending
    BaseTransientBottomBar
    . But it is taking bottom Margin I want it to stick to bottom but it takes some default Bottom Margin. I am using below code to remove the bottom margin
    (view.layoutParams as MarginLayoutParams).setMargins(margin10, 0, margin10, 0)
    Is there any way to remove the bottom margin?
    f
    f
    • 3
    • 8
  • r

    ritesh

    03/16/2020, 1:55 PM
    I have a domain module (contains model and use-cases) and ui-module, ui-module is dependent on domain module. I need to parcelize one of the model of domain-module, but to use it, i need to convert it to android library to take leverage of
    @Parcelize
    Any way, can i make use of
    typealias
    and
    expect
    and
    actual
    without converting the domain pure kotlin module to android module?
    b
    • 2
    • 1
  • d

    dave08

    03/16/2020, 1:56 PM
    It seems like WorkManager's
    CoroutineWorker
    uses
    launch
    to run
    doWork
    , does that mean that a crash can't be caught with a regular try/catch? Does a
    CoroutineExceptionHandler
    need to be installed for that? If so, where?
    a
    • 2
    • 2
  • p

    paulex

    03/16/2020, 2:54 PM
    Good-day guys, So i'm using openapi to generate some kotlin-client code, however i want to be able to use the models as Entity for android ROOM, is there a way to go around this? The models are data classes so i can't extend them
    c
    • 2
    • 9
  • s

    Slackbot

    03/16/2020, 5:49 PM
    This message was deleted.
    s
    s
    s
    • 4
    • 14
  • m

    Marc Knaup

    03/16/2020, 9:34 PM
    IDEA report a type mismatch here while Android Studio doesn’t. Both use latest Kotlin 1.3.70 plugin with New Inference enabled. Why is that? If I try to compile the code that Android Studio accepts, I also get the same error there at compile-time. It’s just the IDE that doesn’t report it. RxJava3’s
    Function…
    is marked
    @FunctionalInterface
    . Is it supposed to work like I’m trying to use it or isn’t it? 🙂
    a
    • 2
    • 2
  • l

    Lumeidagnacadja

    03/16/2020, 10:12 PM
    Hi how to use kotlin khttp lybrarie to make a request in Android App
    s
    • 2
    • 2
  • o

    Ofir Bar

    03/17/2020, 10:11 AM
    My Activity observers 3 `MutableLiveData`in a
    ViewModel
    . I change their values one after another:
    advertisementGoal.value = editModeInitialAdvertisement!!.goal
    advertisementTargetUserType.value = editModeInitialAdvertisement!!.userTypeTarget
    selectedExpertiseField.value = editModeInitialAdvertisement!!.expertiseField.id
    Is this a race condition? or do
    LiveData
    in the UI trigger
    onChange()
    in order?
    a
    • 2
    • 1
  • t

    tjohnn

    03/17/2020, 10:26 AM
    Does this idea of screen state make sense? I want to emit an empty screen state from viewmodel to ui and the screen state has a kotlin lambda inside of it for a call back when a button is clicked. E.g:
    data class (
        val message: String,
        val callback: () -> Unit
    )
    k
    • 2
    • 2
  • j

    Jabez Magomere

    03/17/2020, 11:58 AM
    What is the major difference between a JobIntentService and a JobService?
    t
    • 2
    • 1
  • a

    Alexanderkvamme

    03/17/2020, 12:57 PM
    Guys can anyone give me some advice? I got this screen. The green and white part is a recyclerview with its height set to WRAP_CONTENT. The entire recyclerview is constrained to all edges of the screen, and yet, as you can see, it is centered, with its content being wrapped... What i would expect is the content to be positioned from the top, not from the center. IS there a way to do this?
    a
    • 2
    • 4
  • j

    Joao Birk

    03/17/2020, 8:26 PM
    Hi there, I have a RecyclerView (vertical) with a inner RecyclerView (also vertical). Reason I have that is because the inner RecyclerView has to be wrapped by a CardView and can be collapsed/expanded. Problem is that the inner adapter is not recycling the views and is binding all of them at once, not just the visible ones. Whats the suggestion to solve this problem or another approach to impl this? I thought about creating one single RecyclerView with an item decorator where the first have the card borders (left/top/right), the last have (left/bottom/right) and the others have just the left/right.
    v
    • 2
    • 5
  • i

    itnoles

    03/18/2020, 2:21 AM
    I am trying to use junit 4.13 for unit testing in Android, then I am getting unresolved for it
    a
    • 2
    • 3
  • m

    Madalin Valceleanu

    03/18/2020, 8:20 AM
    📚 Android Sample App using modular, clean, scalable, testable Architecture written in Kotlin that presents modern 2019 approach to Android application development, latest tech-stack and best practices. Application is based, apply and strictly complies with each of the following 5 points: • A single-activity architecture, using the Navigation component to manage fragment operations. • Android architecture components, part of Android Jetpack give to project a robust design, testable and maintainable. • Pattern Model-View-ViewModel (MVVM) facilitating separation of development of the graphical user interface. • S.O.L.I.D design principles intended to make software designs more understandable, flexible and maintainable. • Modular app architecture allows being developed features in isolation, independently from other features. For more technical details please check the project readme. Project link: https://github.com/VMadalin/kotlin-sample-app
    🍻 2
    👍 7
    o
    • 2
    • 1
  • o

    Orhan Tozan

    03/18/2020, 6:52 PM
    Given the following viewmodel:
    class ViewModel {
        val selectedColor: Flow<Color> = ...
        fun onNewColorSelect(newColor: Color) {
            ...
        }
    }
    How can the
    onNewColorSelect
    method update the selectedColor flow? With Android, you would use MutableLiveData. How would you solve this problem with Flow?
    z
    m
    • 3
    • 20
  • j

    jiangxingbing

    03/19/2020, 3:42 AM
    But when I read the decompiled code, I find that the private qualification of object is gone. How to understand this?
    a
    a
    • 3
    • 3
Powered by Linen
Title
j

jiangxingbing

03/19/2020, 3:42 AM
But when I read the decompiled code, I find that the private qualification of object is gone. How to understand this?
a

ahulyk

03/19/2020, 8:30 AM
In java you have: private constructor of class and private member. So incapsulation is not broken.
a

Alexey Belkov [JB]

03/20/2020, 8:01 AM
You can't have a private top-level class in Java. See the docs on Java interop https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html#visibility
private top-level declarations are compiled to package-local declarations
j

jiangxingbing

03/20/2020, 12:05 PM
I found a bigger problem. In the above figure, the database instance built in the Lazy proxy is used, and the migrate set in this way will be optimized by the compiler directly, but no error will be reported.
View count: 2