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
koin
  • p

    Peter Farlow

    04/28/2021, 11:22 PM
    What's the status of the Android work manager library for Koin? It looks incomplete. Any subclass of
    ListenableWorker
    requires both a
    WorkerParameters
    and
    Context
    parameter, but the KoinWorkerFactory doesn't provide the context https://github.com/InsertKoinIO/koin/blob/master/android/koin-androidx-workmanager/src/main/java/org/koin/androidx/workmanager/factory/KoinWorkerFactory.kt
    f
    • 2
    • 1
  • m

    Martin Feldsztejn

    05/01/2021, 2:34 PM
    Are there any plans to support KotlinJs with compiler IR? There’s this PR https://github.com/InsertKoinIO/koin/pull/1067/files that hasn’t been merged yet.
    a
    • 2
    • 4
  • m

    Mark

    05/02/2021, 2:05 AM
    On app startup (in Application subclass) I launch a coroutine to perform certain I/O checks and possibly (first time install, or some app updates) build some databases, imports or migrations. The main activity waits for this to finish (showing a splash/loading fragment) before navigating to a home fragment when all the viewmodel dependencies will be available via Koin. This works fine, except when the app is resumed after being killed in the background. When this happens, the fragment back stack is automatically (I don’t seem to have any control over this) restored and so the viewmodel dependencies are fetched via Koin before the startup I/O has had a chance to complete. How do you handle this?  Should I be coding everything more lazily so that, for example, the first query (triggered by user interaction) would trigger db creation/migration/import etc?  But then wouldn’t this lead to unexpected delays for the user?
    d
    • 2
    • 27
  • c

    Christopher Elías

    05/03/2021, 1:27 PM
    Hello friends! Does anybody knows how to scope objects to the viewmode lifecycle? I have the following "issue" where my mapper object is created twice... I was looking for an option like @Installin(ViewModelComponent::class) does in dagger-hilt but im unable to find it. https://github.com/InsertKoinIO/koin/issues/1080
    a
    • 2
    • 6
  • e

    eurycea

    05/03/2021, 9:05 PM
    Where should I look for current documentation / examples of how to set up SavedStateHandle usage in 3.0.1? I am getting very confused looking at different documentation and answers to old issues.
    • 1
    • 1
  • r

    rsetkus

    05/04/2021, 11:02 AM
    Hi. Just upgraded Koin to
    3.0.1
    on Kotlin Multiplatform project and started getting error:
    java.lang.IllegalStateException: e: Failed to resolve Kotlin library: /Users/.../build/kotlinSourceSetMetadata/commonMain/io.insert-koin-koin-core/io.insert-koin-koin-core-commonMain.klib
    Building successfully for Android platform but getting error for iOS. Anybody else experienced anything similar?
    j
    • 2
    • 4
  • n

    nikolaymetchev

    05/06/2021, 10:12 AM
    Sticking to koin
    3.0.1
    what happened to the
    environmentProperties()
    method ? Does koin automatically do that now? Or is this feature gone? Is there a migration guide from 2 to 3?
    a
    • 2
    • 3
  • h

    Helio

    05/10/2021, 7:11 AM
    Hello 👋🏽 I was wondering if anyone here could shed me some light and explain why I’m getting the following error:
    org.koin.core.error.NoBeanDefFoundException: No definition found for class:'com.atlassian.buildeng.pipeline.compliant.checker.service.BuildInfoService'. Check your definitions!
    The class that it is complaining about, it is actually an
    interface
    interface BuildInfoService<T : HttpRequestParamsModel, out P> {
        suspend fun getBuildInfo(httpRequestParamsModel: T): P
    }
    I’m currently trying to configure my Koin test module with classes that implement that interface. In my definition, I’m adding qualifier to everything. Example:
    val testModule = module {
        ...
        single<BuildInfoService<ModelA, TypeA>>(named("BuildInfoService_A")) { MyClassA(get(named("ServiceA"))) }
        single<BuildInfoService<ModelB, TypeB>>(named("BuildInfoService_B")) { MyClassB(get(named("ServiceB")), get(named("ServiceA"))) }
        ...
    }
    Just to complement a bit further, the project is running
    Koin = 2.2.2
    and
    Ktor=1.5.1
    . Any help would be greatly appreciated.
    t
    • 2
    • 28
  • y

    Yahor

    05/15/2021, 5:38 PM
    Hello, I have upgraded to 3.0.1 version and looks like Koin doesn’t work with Dynamic feature anymore. Previously I loaded module during class creation like this:
    class PostCreatorFragment : ScopeFragment(R.layout.fragment_post_creator) {
    
        init {
            loadKoinModules(postModule)
        }
    
        override fun onDestroy() {
            super.onDestroy()
            unloadKoinModules(postModule)
        }
    }
    Now I receive following error:
    org.koin.core.error.NoScopeDefFoundException: No Scope Definition found for qualifer 'com.egoriku.ladyhappy.postcreator.presentation.PostCreatorFragment'
            at org.koin.core.registry.ScopeRegistry.createScope(ScopeRegistry.kt:126)
            at org.koin.core.Koin.createScope(Koin.kt:208)
            at org.koin.core.Koin.createScope$default(Koin.kt:204)
            at org.koin.androidx.scope.FragmentExtKt$fragmentScope$1.invoke(FragmentExt.kt:29)
            at org.koin.androidx.scope.FragmentExtKt$fragmentScope$1.invoke(Unknown Source:2)
            at org.koin.androidx.scope.LifecycleScopeDelegate.<init>(LifecycleScopeDelegate.kt:30)
            at org.koin.androidx.scope.LifecycleScopeDelegate.<init>(LifecycleScopeDelegate.kt:19)
            at org.koin.androidx.scope.FragmentExtKt.fragmentScope(FragmentExt.kt:28)
            at org.koin.androidx.scope.ScopeFragment.<init>(ScopeFragment.kt:38)
            at org.koin.androidx.scope.ScopeFragment.<init>(ScopeFragment.kt:35)
    Looks like
    _scopeDefinitions
    don’t contain my scope from dynamic feature Source code: https://github.com/egorikftp/Lady-happy-Android/blob/e2fbec6c4f581b84e390caa4958e7[…]oriku/ladyhappy/postcreator/presentation/PostCreatorFragment.kt @arnaud.giuliani Could you please assist or its better to create issue on github?
    j
    m
    a
    • 4
    • 6
  • s

    Sergio Crespo Toubes

    05/18/2021, 11:40 AM
    Hello, i am having a problem that i cant resolve. I have a shared ViewModel in child and parent fragment. I want when a child fragment click a button, parent fragment read
    MutableLiveData
    change and load another fragment with navigation component. Any idea? THANKS.
    a
    • 2
    • 2
  • a

    arnaud.giuliani

    05/20/2021, 8:30 AM
    let’s see how it goes
    ✅ 1
    j
    a
    n
    • 4
    • 14
  • m

    Mark

    05/20/2021, 9:18 AM
    When upgrading koin from 3.0.1 to 3.0.2, my unsigned literals (e.g.
    var foo = 0u
    ) suddenly give the error
    Type of the constant expression cannot be resolved. Please make sure you have the required dependencies for unsigned types in the classpath
    . Any ideas?
    a
    • 2
    • 6
  • e

    eurycea

    05/20/2021, 3:12 PM
    Is anyone successfully running an Espresso KoinTest that injects a mocked (with mockk) ViewModel via stateViewModel? Is there a trick to getting around getTag needing to return SavedStateHandleController?
    • 1
    • 1
  • a

    Artem

    05/21/2021, 1:35 PM
    Is there a way to copy or clone Koin scope as new scope instance?
    • 1
    • 1
  • n

    Nacho Ruiz Martin

    05/22/2021, 4:03 PM
    Anyone achieved to inject a ViewModel on a compose Preview? Does it even make sense? What's the best approach to be able to preview a screen?
    a
    • 2
    • 2
  • s

    Slackbot

    05/28/2021, 6:03 AM
    This message was deleted.
    a
    s
    • 3
    • 3
  • a

    arnaud.giuliani

    05/29/2021, 8:36 AM
    A proposal for Google Android Architecture Samples, but  with Koin - https://github.com/android/architecture-samples/issues/789
    :thank-you: 1
    👍 7
    e
    s
    m
    • 4
    • 4
  • l

    Lena Stepanova

    06/01/2021, 12:27 PM
    Hi, I've spent the whole day trying to understand why I suddenly get org.koin unresolved error. I think, after I changed dependencies some time ago to io.insert-koin, the project kept working on cached libraries. Today I invalidate the caches and cannot use KoinComponent anymore. It's a Kotlin Multiplatform project. I would really appreciate any help! Funnily, the project builds and runs from develop branch, but doesn't from another working branch. And I'm sure I haven't done anything to koin or other dependencies there 🤯
    a
    • 2
    • 28
  • a

    Alexa_Gal

    06/03/2021, 9:03 AM
    Hi guys, anyone knows any workaround how to fix this https://github.com/InsertKoinIO/koin/issues/1098 until Koin releases next version?
    a
    • 2
    • 9
  • j

    James Black

    06/07/2021, 5:52 AM
    I upgraded today to compose 1.0.0-beta08, and my compose compiler is the same and for koin-android I am on 3.0.2, but 3.0.1 for koin-androidx-compose and kotlin is 1.5.10. When I call
    val passwordHelperViewModel = getViewModel<ViewModel>()
    I get this error
    java.lang.NoSuchMethodError: No interface method startReplaceableGroup(ILjava/lang/String;)V in class Landroidx/compose/runtime/Composer
    Is there a version of koin that is coming out that will allow this to work, as I would hate to change everything back to kotlin 1.4.32.
    c
    • 2
    • 3
  • x

    xxfast

    06/08/2021, 3:41 AM
    does koin support the new kotlin js IR backend ? If not, are there plans to?
    a
    • 2
    • 1
  • e

    Evan

    06/09/2021, 8:09 PM
    Hey everyone, I’m using Koin in a multiplatform project, and I’m having an issue on iOS/Swfit retrieving Kotlin objects from my Koin application. I’m using the extension methods for
    get
    from the KampKit project, but for some objects I get a
    EXC_BAD_ACCESS
    crash. Can anyone point me to what I’m doing wrong? Snippets in comments.
    r
    a
    • 3
    • 13
  • u

    ushort

    06/09/2021, 10:00 PM
    Hello, just setup koin and it's requiring me to pass class of dependency inside inject. I was under the impression this was doable simply how I have it. For some reason its using inject from KotlinJavaComponent
    class A {
        val b by inject<B>() // How I expected it to be done (based off codes samples I've seen)
        val b by inject<B>(B::class.java) // Requiring me to do it this way
    }
    d
    c
    • 3
    • 3
  • x

    xxfast

    06/11/2021, 7:15 AM
    Hi all - i’m getting this error thrown
    TypeError: elements.iterator_62 is not a function
    while trying to consume koin from a typescript client. More code in the thread
    • 1
    • 1
  • m

    Marek Hlava

    06/11/2021, 9:47 AM
    Hello all, I'd like to know when to expect updates to be available after a release 🙂 I can see 3.1.0 released 2 hours ago on GitHub https://github.com/InsertKoinIO/koin/releases But it hasn't reached Maven yet https://search.maven.org/search?q=io.insert-koin How long does it usually take?
    m
    • 2
    • 3
  • a

    aipok

    06/11/2021, 10:02 AM
    in 3.1.0 this definition is deprecated. Could you describe how this
    parameters.get()
    intent to be used?
    a
    • 2
    • 13
  • p

    Paul Davies

    06/11/2021, 10:18 AM
    Just grabbed
    3.1.0
    (thanks!) Am getting the following error. Is there a release of `io.insert-koin:koin-androidx-compose`as well (latest i'm seeing is
    3.0.1
    ), or am I just missing an API change?
    @Composable
    fun EntryDetailScreen(id: EntryId) {
        val viewModel = getViewModel<EntryDetailViewModel> { parametersOf(id) }
    }
    Type mismatch: inferred type is ParametersHolder but DefinitionParameters was expected
    a
    j
    • 3
    • 6
  • m

    Mini

    06/12/2021, 1:20 PM
    Were there any changes to state viewmodel in 3.1.0? Since upgrading the following has started crashing 😞
    val vm : MyVm = getStateViewModel(state = { bundleOf(Pair("key", value)) })
    a
    • 2
    • 3
  • r

    russhwolf

    06/12/2021, 3:38 PM
    Seems like there’s breaking changes to
    checkModules()
    in 3.1.0. Nothing in the changelog about it. What’s the story there? I’m having trouble understanding how to migrate my tests from the lambda-based setup I had before.
    j
    a
    • 3
    • 18
  • m

    Marcin Wisniowski

    06/12/2021, 5:00 PM
    Hello, I am a little confused with the Koin versions. I was using v2 on Android, but I see that v3 exists, and it has a new group name
    io.insert-koin
    , however in the Android docs it still has imports with
    org.koin
    . So which am I supposed to use? Android docs tell me to use
    org.koin
    imports, but the main setup docs tell me to not do that.
    r
    a
    • 3
    • 5
Powered by Linen
Title
m

Marcin Wisniowski

06/12/2021, 5:00 PM
Hello, I am a little confused with the Koin versions. I was using v2 on Android, but I see that v3 exists, and it has a new group name
io.insert-koin
, however in the Android docs it still has imports with
org.koin
. So which am I supposed to use? Android docs tell me to use
org.koin
imports, but the main setup docs tell me to not do that.
I thought I'd stay on v2 for now, but it's on jCenter, which is deprecated, so I can't do that.
r

russhwolf

06/12/2021, 5:34 PM
the gradle group name changed as part of the maven central migration, but the package names in code didn’t
☝️ 1
m

Marcin Wisniowski

06/12/2021, 11:34 PM
Sorry, didn't mean imports. It's just that https://insert-koin.io/docs/quickstart/android-viewmodel has dependency declarations for
org.koin
, but https://insert-koin.io/docs/setup/v3 has different ones, and it isn't clear which page supersedes which.
r

russhwolf

06/12/2021, 11:40 PM
Ah I see. The first link is out-of-date.
👍 1
a

arnaud.giuliani

06/14/2021, 8:07 AM
yep
View count: 7