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

    Pablichjenkov

    11/22/2022, 10:52 PM
    Is there subcomponents or similar to Dagger subcomponents in Koin? I want to be able to create these dependencies subgraph on the fly as the user browse the different sessions of the App. Similar to component dependency in Dagger. What is the closest approach?
    a
    • 2
    • 3
  • k

    KotlinLeaner

    11/24/2022, 6:29 AM
    Hi @arnaud.giuliani, I used
    @Preview
    annotations in my function, but I am getting error on design issues message.
    This preview was unable to find a CompositionLocal. You might need to define it so it can render correctly. Show Exception
    j
    • 2
    • 6
  • k

    KotlinLeaner

    11/24/2022, 7:00 AM
    Hi, another question what is difference between
    getViewModel()
    or
    koinViewModel()
    in compose function?
    a
    • 2
    • 3
  • h

    humblehacker

    11/30/2022, 2:34 AM
    I'm new to Koin and ran across something that was unexpected and I'd like to know if I'm either understanding it wrong, or doing it wrong. I've got a dependency declared as
    factory { Service() }
    , and I'm attempting to use it in a class as a property declared as
    val service: Service by inject()
    . It works, but it seems that every time I reference that property in my class, Koin creates a new instance. Is that how it's supposed to work? I expected it to construct the
    Service
    lazily, but after that I'd get the same instance until the parent class is destroyed. Changing
    by inject()
    to
    = get()
    gets me the behavior I want, but I really want to know why
    by inject()
    isn't working as I expect.
    s
    • 2
    • 4
  • d

    Davide Giuseppe Farella

    12/12/2022, 5:29 AM
    Good morning. I’m converting my app to Koin annotations ( 3.2.2 + 1.0.3 ) and I think I found one ( two? ) issue(s). After converting all my modules, I have an “aggregator”, like
    @Module(includes = [...])
    class MyAppModule {
    
      // couple of defs here
    }
    And here’s the first issue: the generated code has syntax issues, like
    includes(.SomeModule
    ( note the
    .
    before the name and missing qualifier ) Since in the
    includes = [...]
    I had about 50 modules, I thought I broke the processor, so I grouped them into other modules like
    @Module(includes = [A::class, B::class])
    class MyAppModule {
    
      // couple of defs here
    }
    
    @Module(includes = [...])
    class A
    
    @Module(includes = [...])
    class B
    But seems like
    A
    and
    B
    are not processed, as there is generated code only for
    MyAppModule
    a
    • 2
    • 11
  • z

    Zach

    12/14/2022, 11:42 PM
    Can you mix koin-core & koin-android in 3.3.0? Upgrading to 3.3.0 gave me some odd exceptions at runtime with
    startKoin
    and
    androidLogger
    import org.koin.android.ext.koin.androidContext
    import org.koin.android.ext.koin.androidLogger
    import org.koin.core.context.startKoin
    
    class MainApplication : Application() {
        @Suppress("SpreadOperator")
        override fun onCreate() {
            super.onCreate()
            startKoin {
                androidLogger()
                androidContext(this@MainApplication)
                modules(*allModules)
            }
        }
    }
    java.lang.LinkageError: Method void org.koin.android.logger.AndroidLogger.log(org.koin.core.logger.Level, java.lang.String) overrides final method in class Lorg/koin/core/logger/Logger; (declaration of 'org.koin.android.logger.AndroidLogger'
    a
    • 2
    • 4
  • a

    arnaud.giuliani

    12/15/2022, 5:33 PM
    Hi there 👋 several updates for koin projects: `- koin-core`& `koin-test`updated in 3.3.0 -
    koin-android
    update in 3.3.1 - `koin-androidx-compose`in 3.4.0 https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md
    m
    • 2
    • 3
  • a

    arnaud.giuliani

    12/15/2022, 5:33 PM
    also upates to come for `koin-ktor`and
    koin-annotations
  • a

    arnaud.giuliani

    12/15/2022, 5:33 PM
    A bit of reading about Koin in NowInAndroid app: https://proandroiddev.com/now-in-android-with-koin-part-1-2b871d8549f1
  • a

    Agustin Bonilla

    12/16/2022, 12:15 AM
    Hi everyone! I’m using a library that, as I can see, has dependencies on koin-android 3.1.6 and also on koin-core 3.1.6. As a limitation on my side, I can only add those dependencies on AAR or JAR files. I have found and added the koin-android AAR and the koin-core JAR, but when I run my app I’m having the following error: “Failed resolution of: Lorg/koin/dsl/KoinApplicationKt” It looks like haven’t found the class KoinApplication that if I’m right, it should be in the koin-core JAR. Does anyone know why it isn’t finding the class KoinApplication? Do I have to use a specific koin-core JAR file? Is there a koin-core AAR version to try?
    a
    e
    • 3
    • 12
  • r

    Robert Jaros

    12/16/2022, 6:59 PM
    Why is
    koin-ktor
    repository archived? Is this module deprecated? How should we use Ktor with new Koin release?
    j
    a
    • 3
    • 5
  • z

    zt

    12/18/2022, 11:57 PM
    What is the reasoning behind making koin-compose depend on androidx navigation? It brings in the androidx navigation library, even though I'm using a different implementation. I've been staying on a previous version that does not add androidx nav, but then I am losing bug fixes and new features. Could this be fixed?
    a
    x
    • 3
    • 5
  • e

    Emanuel Moecklin

    12/20/2022, 12:56 AM
    When I try to use annotations in an Android library I get
    Could not determine the dependencies of task ':feature1:extractDebugAnnotations'.
    > Could not create task ':feature1:kspDebugKotlin'.
       > Could not create task of type 'KspTaskJvm'.
          > org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptionsImpl
    Is there a gradle.build.kts example for the setup? https://insert-koin.io/docs/setup/ka_1.0/ only has the Groovy code like
    android {
        applicationVariants.all { variant ->
            variant.sourceSets.java.each {
                it.srcDirs += "build/generated/ksp/${variant.name}/kotlin"
            }
        }
    }
  • h

    holgerbrandl

    12/20/2022, 11:31 AM
    Hi there, I've noticed a behavioral change between 3.1.1 and 3.2.1 (which is also present in 3.3.0). It seems that objected are not loaded eagerly anymore. Consider the following example:
    import org.koin.dsl.koinApplication
    import org.koin.dsl.module
    
    data class Tester(val id:String, val created :Long ){
        init{
            println("creating $this")
        }
    }
    
    fun main() {
        val myModule=  module(createdAtStart = true) {
            single(createdAtStart = true){
                Tester("A", System.nanoTime())
            }
        }
    
        val koinApplication = koinApplication {}
        val koin = koinApplication.koin
        koin.loadModules(modules = listOf(myModule))
    
        println("everything loaded?")
    
        println(koin.get<Tester>())
    }
    The print order changes between the mentioned versions. To me this qualifies as a bug.
    a
    • 2
    • 4
  • x

    xxfast

    12/22/2022, 5:30 AM
    Hello! I'm migrating from 3.1.4 -> 3.3.0 Looking at this, does this mean if you are not using androidx-navigation NavBackStackEntry as your ViewModelStoreOwner - we no longer can use these extensions?
    a
    s
    • 3
    • 5
  • p

    Partho Paul

    12/28/2022, 1:59 PM
    Hi, I’m getting this error:
    Property delegate must have a 'getValue(Nothing?, KProperty<*>)' method. None of the following functions is suitable: public inline operator fun <T> Lazy<???>.getValue(thisRef: Any?, property: KProperty<*>): ??? defined in kotlin
    in this line:
    val slackCommandListener by inject<SlackCommandListener>()
    My listener is defined in koin as follows:
    //in modules.kt
    val listenerModule = module {
        factory { SlackCommandListener(get(), get()) }
    }
    
    //in koin.kt
    install(Koin) {
            slf4jLogger(level = org.koin.core.logger.Level.ERROR)
            modules(serviceModule, controllerModule, listenerModule)
    }
    Can someone please help? T.I.A.
    a
    • 2
    • 1
  • b

    Big Chungus

    12/29/2022, 1:47 PM
    Hi all. I've recently decided to give koin a go (after tears of using #kodein) ans can't help but wonder what's up with artefact versions being all over the place? Is there koin bom I could pull in to manage them?
    a
    • 2
    • 5
  • e

    Elio Maroun

    12/29/2022, 1:47 PM
    https://stackoverflow.com/questions/74951871/i-have-nested-scopes-but-injection-is-not-working
  • a

    Adam Brown

    01/03/2023, 7:57 PM
    is there any way when creating a scope to pass a parameter that we live inside that scope? got an identifier that everything created in that scope needs passed into it. currently I do it with an inject parameter, but it would be nice to clean up all of my injection sites by just having that one common parameter live inside the scope itself
    a
    • 2
    • 2
  • a

    Adrian Witaszak

    01/20/2023, 8:41 AM
    Any recommended way of using Koin with JB Compose in the project with shared UI in shared? Right now, i use my own Injector interface with Impl as KoinComponent, but I wonder if there is an existing Koin solution in place.
    p
    a
    • 3
    • 14
  • s

    Seb Jachec

    01/23/2023, 3:19 PM
    Hi, I’m trying to migrate from 3.2.2 to 3.3 in a multiplatform project. A number of
    singleOf
    declarations in the format below are now unable to be resolved at compile time. How should I be migrating these? I couldn’t seem to find any migration guide or detail of this in the changelog, unless I’ve missed something!
    module {
        // ...
    	singleOf { a, b, c -> SomeFactory(a, b, c).build() }
    }
    
    // Compiler error:
    // None of the following functions can be called with the arguments supplied: ...
    // public inline fun <reified R> Module.singleOf(...
    // etc ...
    p
    a
    • 3
    • 13
  • t

    Trym Nilsen

    01/26/2023, 12:32 PM
    I’m trying to migrate some code to compose and have come across a scenario where I have a viewmodel defined in an activity with koin and would like to use this inside of a composable within a composeview in this activity. What would be the easiest way of doing this? My old non-migrated fragment used
    by activityViewModel<...>()
    and i wondered if there is something similar or what i would need to pass to the
    getViewModel
    composable to get the same result.
    p
    a
    • 3
    • 3
  • d

    Dan Rusu

    01/28/2023, 8:22 PM
    What's the best practice for using Koin when creating libraries? I'm just starting to explore Koin and noticed that I need to initialize everything with
    startKoin
    but libraries don't typically have a main entry point so I'm wondering how to approach DI when creating libraries
    b
    a
    • 3
    • 10
  • j

    James Black

    01/29/2023, 2:19 AM
    I am trying to use annotations in my KMP application, but I have an error that I can't work around. I am using code from HelloWorld-KMP, using the annotations branch. A problem occurred configuring project ':androidApp'.
    Could not create task ':androidApp:compileDebugKotlin'.
    > Cannot convert the provided notation to a File or URI: [/Users/jamesblack/AndroidStudioProjects/MyPasswordSafe/androidApp/build/generated/ksp/debug/kotlin].
    a
    • 2
    • 3
  • s

    spechard

    01/31/2023, 8:48 PM
    Hi, I try to understand if scope is suitable to what I wanna do, but I can’t make this simple example to work. Can anyone help me making this test run successfully (see thread). Thanks a lot!
    a
    • 2
    • 12
  • k

    KamilH

    02/02/2023, 8:26 AM
    Recently I faced a problem with
    ViewModel
    not working correctly with
    Qualifier
    . The issue is described here. Is there any workaround I can apply until it’s resolved?
    p
    a
    • 3
    • 5
  • h

    Hossein Amini

    02/03/2023, 12:18 PM
    Is there anyone who used Koin annotation in a real KMM project? I’m trying to use it but it does not resolve
    org.koin.ksp.generated.module
    even in the Koin sample project https://github.com/InsertKoinIO/hello-kmp
    p
    m
    a
    • 4
    • 26
  • s

    spechard

    02/07/2023, 9:13 PM
    Hi all, How do you pass parameters to a scope? I can define like this:
    scope(named<Example>()) {
        scoped { params -> Example(name = params.get()) }
    }
    but how do I resolve the instance in the scope afterwards? Thanks!
    a
    a
    • 3
    • 3
  • e

    Eugen Martynov

    02/10/2023, 12:46 PM
    Hi people, where I can find koin compose changelog?
  • e

    Eugen Martynov

    02/10/2023, 12:47 PM
    Or here (https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md) is attempt to have it?
    a
    • 2
    • 6
Powered by Linen
Title
e

Eugen Martynov

02/10/2023, 12:47 PM
Or here (https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md) is attempt to have it?
a

arnaud.giuliani

02/14/2023, 11:02 AM
koin-test has no update, apart of koin-core update
for compose, it’s also just an update from koin-android 3.3.3 under the hood
e

Eugen Martynov

02/14/2023, 11:16 AM
Thank you Arnaud, would be great to have it reflected in changelog
a

arnaud.giuliani

02/15/2023, 2:55 PM
Online, there is something like that:
https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md#androidx-compose-342---2022-02-07
hope it can help
View count: 8