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

    andym

    06/17/2020, 4:25 AM
    Can I use Kotlin contracts to validate a minimum Android SDK level? I’m hoping for something like the following, to encapsulate the version test with the feature test:
    `at`ExperimentalContracts
    fun isMyFeatureSupported(): Boolean {
        contract {
            // The implies expression fails to build with "Error in contract description:  unsupported construction"
            returns(true) implies (Build.VERSION.SDK_INT >= BUILD.VERSION_CODES.something)
        }
    
        return (Build.VERSION.SDK_INT >= BUILD.VERSION_CODES.something) &&
                myFeatureTest()
    }
    t
    • 2
    • 3
  • s

    Shubham11207

    06/17/2020, 9:46 AM
    Hi everyone. I published my app using bundles on play store a few days ago but it's not getting compatible with all devices. May I know what can be the issue. I have checked all the permission in the manifest. but unable to understand. 😞 Anyone pls suggest something
    :stackoverflow: 2
    s
    • 2
    • 2
  • a

    Ananiya

    06/17/2020, 1:26 PM
    hello there , my app is crashing 💥 and returning null path error in piccasso while i am sending text to server, hence i protect every code with "*IfNotNull(
    if(x != null)
    )*" i spend over 1 n half week stucked trying to solve this problem 😭 please please help me
    theerror.kt
    z
    m
    • 3
    • 15
  • m

    mending3

    06/17/2020, 3:05 PM
    viewModelScope.launch {
        try {
            val apiRes = AccountRepository().connect.createAccount(accountName.value, phoneNumber.value?.toInt())
            _showNotif.postValue("success")
        } catch (throwable: Throwable) {
            when (throwable) {
                is IOException -> _showNotif.postValue(throwable.message)
                is HttpException -> _showNotif.postValue("${throwable.code()}")
                else -> _showNotif.postValue(throwable.message)
            }
        }
    }
    I want to catch an exception from retrofit. the api returns 500. however why does the viewModelScope return me the success message indicated by
    _showNotif.postValue("success")
    code?
    r
    j
    • 3
    • 16
  • r

    Rita Okonkwo

    06/17/2020, 3:46 PM
    Hey people good day. Please has anyone worked with exoplayer in a recyclerview using Kotlin? I have a few questions
    👋 4
    t
    • 2
    • 2
  • m

    Mark

    06/18/2020, 4:01 AM
    Anyone else experiencing super-annoying inserted linebreaks when moving source files within Android Studio? For example:
    val normalized =
        normalize(
            flds[0]
        )
    If I select the single-line version of this and perform “Reformat code” then it doesn’t change, so I don’t think this is due to code formatting settings. And to be clear, it’s nowhere near hitting the line length limit.
    :yes: 13
    l
    • 2
    • 2
  • s

    Striker

    06/18/2020, 8:51 AM
    I was using live data with paging library 2 but now i upgraded to paging 3..I have a listData(which is a flow that returns paging data) and a searchQuery(livedata) and filterBy(livedata) so whenever i change it i also need the pagingdata to be updated...should i use MediatorLiveData ? Or is there any method using slow for this ?
    o
    • 2
    • 8
  • r

    Reiko

    06/18/2020, 2:07 PM
    I added to this issue today. Maybe someone has a good idea for you to solve? https://github.com/jaredrummler/ColorPicker/issues/90
    :stackoverflow: 3
    a
    • 2
    • 1
  • d

    Davide Giuseppe Farella

    06/18/2020, 4:56 PM
    Hello, I wrote a Multiplatform testing library that includes backticks named functions. I’ve packed and shipped via Bintray, I’ve included in tests of my Android project. Tests are running just well, but when I build the project I got:
    > Transform artifact assert4k-jvm-0.2.2.jar (studio.forface:assert4k-jvm:0.2.2) with DexingWithClasspathTransform
    AGPBI: {"kind":"error","text":"Class descriptor 'Lassert4k/CollectionKt$is not$2;' cannot be represented in dex format.","sources":[{}],"tool":"D8"}
    
    > Task :app:mergeExtDexBetaDebugAndroidTest FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:mergeExtDexBetaDebugAndroidTest'.
    > Could not resolve all files for configuration ':app:betaDebugAndroidTestRuntimeClasspath'.
       > Failed to transform assert4k-jvm-0.2.2.jar (studio.forface:assert4k-jvm:0.2.2) to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
          > Execution failed for DexingWithClasspathTransform: /Users/davide/.gradle/caches/modules-2/files-2.1/studio.forface/assert4k-jvm/0.2.2/3c15ade7f5afff280c26ca8346b645c620f3af76/assert4k-jvm-0.2.2.jar.
             > Error while dexing.
    Any idea?
    c
    l
    • 3
    • 7
  • m

    mending3

    06/19/2020, 3:30 AM
    i've got gradle error without error message. what should I do next?
    s
    a
    l
    • 4
    • 3
  • j

    Jeff

    06/19/2020, 7:16 AM
    I get this error while running ./gradlew assembleQaDebugAndroidTest in my project. What could be the problem and how can I fix it? It's about duplicate classes with androidx/appcompat. Thanks for the help in advance! 🙂
    Execution failed for task ':commons:ui:checkQaDebugAndroidTestDuplicateClasses'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
    > Duplicate class androidx.appcompat.content.res.AppCompatResources found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.content.res.AppCompatResources$ColorStateListCacheEntry found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$1 found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimatableTransition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimatedStateListState found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimatedVectorDrawableTransition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$AnimationDrawableTransition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$FrameInterpolator found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat$Transition found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer$1 found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer$BlockInvalidateCallback found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.DrawableContainer$DrawableContainerState found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.DrawableWrapper found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.StateListDrawable found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.graphics.drawable.StateListDrawable$StateListState found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.widget.DrawableUtils found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.widget.ResourcesWrapper found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.widget.TintContextWrapper found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.widget.TintInfo found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.widget.TintResources found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    Duplicate class androidx.appcompat.widget.VectorEnabledTintResources found in modules appcompat-1.0.0-runtime (androidx.appcompat:appcompat:1.0.0) and jetified-appcompat-resources-1.1.0-runtime (androidx.appcompat:appcompat-resources:1.1.0)
    m
    • 2
    • 2
  • s

    Saket Poddar

    06/19/2020, 11:52 AM
    Can anyone tell me why bundles are serialisable ?
    :stackoverflow: 2
    a
    r
    • 3
    • 7
  • j

    JerryMiah

    06/19/2020, 5:37 PM
    I’m sorry if this has already been debated in here but I really want to get people’s opinions about Koin vs Hilt. I work on an app that was originally using Dagger 2 but we switched over to Koin over a year ago and I really like it compared to Dagger 2. Now that Hilt is out I’m facing a tough decision of whether or not I switch to it. Koin has worked really well for the app I work on and it has solved a lot of problems that Dagger 2 struggles with. Hilt seems to simplify things over Dagger 2 but it seems as though Koin still has the upper hand in certain areas. Hilt is backed by Google and supposedly has a better performance so I’m faced with a tough decision.
    a
    r
    +9
    • 12
    • 15
  • v

    vapoyan

    06/20/2020, 2:53 PM
    Hey Guys. please help me I am struggling with this question already few days, and not able to find a solution. The issue is related to DataBinding and Custom Attributes https://stackoverflow.com/questions/62487298/android-databinding-with-custom-attribute-does-not-work
    r
    r
    • 3
    • 2
  • t

    TarunY

    06/21/2020, 8:04 AM
    Hey guys, I’m using vlc-android in order to play RTSP live stream in my android application. the following code renders the stream video onto the texture view. but i need to get the current frame each interval of time to perform image processing on it. please help me in resolving this issue.
    r
    • 2
    • 2
  • z

    zalewski.se

    06/21/2020, 1:39 PM
    Has anyone experience any problem with new Android Studio (beta or canary) where it keeps reseting coding style setting back to default values?
    m
    • 2
    • 1
  • m

    mending3

    06/22/2020, 8:52 AM
    do anyone have example of splash screen with jetpack navigation?
    z
    • 2
    • 2
  • s

    starke

    06/23/2020, 2:19 AM
    ‘|pmn'?
    s
    • 2
    • 2
  • m

    Manpreet Kunnath

    06/23/2020, 9:22 AM
    message has been deleted
    j
    s
    • 3
    • 14
  • r

    Roman Abaev

    06/23/2020, 12:05 PM
    Hello, is there any example with jetpack compose BottomAppBar?
    j
    a
    • 3
    • 8
  • s

    Sijan Rijal

    06/24/2020, 4:37 AM
    Which one do you recommend to build Android UI? Flutter or Jetpack Compose? And what are some of the benefits Compose has over Flutter? Do you have free resources to learn Compose?
    s
    z
    • 3
    • 3
  • s

    Sijan Rijal

    06/24/2020, 4:43 AM
    I'm currently learning Android development but most of the topics have already been deprecated. What resources would you suggest to learn the latest development tools and practices?
    s
    j
    • 3
    • 2
  • v

    Viresh

    06/24/2020, 10:33 AM
    Hello, I am bit new to Kotlin multi platform and trying to create a multi platform module to be used in our iOS and android apps. I have few questions if somebody can provide me more info or redirect me to correct documentation: 1. How can I specify minimum iOS version & target iOS version for iOS frameworks rather than going with default one? 2. Is there any limitation on what Apple's iOS native framework we can use from Kotlin module? I was trying to import
    Combine
    framework but was not able to do.
    j
    • 2
    • 2
  • s

    Saurabh

    06/24/2020, 12:54 PM
    Can I use interface implementation by delegates with an activity? I mean, normally, we pass the delegate object through constructor, but here, we don't construct the activity's object. Is delegation possible with objects not created at constructor invocation?
    a
    • 2
    • 1
  • i

    Isaac

    06/24/2020, 2:24 PM
    Hello. I am trying to get the full path of an image selected from gallery while following Scoped Storage rules, but I'm struggling with it. Can anyone help?
    i
    • 2
    • 4
  • m

    Matiasdelbel

    06/24/2020, 3:03 PM
    Hello! I've created a
    src/main
    folder inside the
    buildSrc
    folder... Is there a way I can access to the files inside
    src/main
    from the
    build.gradle.kts
    file?
    l
    • 2
    • 18
  • p

    pucherd

    06/25/2020, 8:21 AM
    Hello, I am currently working on a multiplatform library (android/iOS). After updating the Kotlin plugin to 1.4-M2 the sourceSets for commonMain are not published (only the platform specific sets). It is working with Kotlin plugin 1.3.72. Any Idea why?
    i
    • 2
    • 1
  • n

    Noel Nwaelugo Orisaemeka

    06/25/2020, 4:54 PM
    Hello here, I have an Image view that can be zoomed and scaled. How can I get the coordinates or bounds of the zoomed image and use it to set up the same image in another activity/fragment. I don't want to crop the view or use a bitmap. Is this possible please? Any help would be sincerely appreciated.
    o
    • 2
    • 1
  • v

    vesp

    06/25/2020, 7:42 PM
    Hey everyone I'm playing with
    Glide
    ,
    Bitmap
    ,
    Canvas
    , and
    Paint
    and I managed to create code to apply a mask using
    PorterDuff
    . Although I managed to complete the task, the Kotlin is kinda unsightly. Can I have some help trying to make function look more like Kotlin? I'm a junior-ish dev so any insights can help. I can DM code or share in comments.
    j
    • 2
    • 15
  • l

    lawlorslaw

    06/26/2020, 12:30 AM
    Hey are there any recommendations how i can simplify the creation of a viewmodel across all my features. Right now I have it set up like this. I tried briefly looking into Kotlin delegates but I haven’t come across an example that didnt seem overly complicated. I would like to continue to use Dagger and not switch to a different dependency injection framework.
    Untitled
    i
    m
    • 3
    • 2
Powered by Linen
Title
l

lawlorslaw

06/26/2020, 12:30 AM
Hey are there any recommendations how i can simplify the creation of a viewmodel across all my features. Right now I have it set up like this. I tried briefly looking into Kotlin delegates but I haven’t come across an example that didnt seem overly complicated. I would like to continue to use Dagger and not switch to a different dependency injection framework.
Untitled
i

Isaac

06/26/2020, 8:18 AM
You could look into using Hilt, it'll surely give you a more elegant way to create your ViewModels
m

Matiasdelbel

06/26/2020, 1:55 PM
Yes, you could use hilt... Also, if you want to continue using dagger, you can use android-dagger... finally, androidX provides you some extension function to create a view models
val viewModel by viewModels {  }
View count: 5