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
kodein
  • t

    turansky

    10/04/2019, 2:26 PM
    After migration on
    6.4.0
    from
    6.3.3
    doesn't work following JS tests JS lib (target browser) -> MPP lib (jvm { target 1.8 }, js { browser {} }) If JS lib contains test, than:
    Caused by: java.lang.NullPointerException
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnImportedPackagesVersionResolver.updateVersionsMap(YarnImportedPackagesVersionResolver.kt:79)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnImportedPackagesVersionResolver.updatePackageJson(YarnImportedPackagesVersionResolver.kt:71)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnImportedPackagesVersionResolver.updatePackages(YarnImportedPackagesVersionResolver.kt:63)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnImportedPackagesVersionResolver.resolveAndUpdatePackages(YarnImportedPackagesVersionResolver.kt:29)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnWorkspaces.saveRootProjectWorkspacesPackageJson(YarnWorkspaces.kt:51)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnWorkspaces.resolveWorkspaces(YarnWorkspaces.kt:35)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnWorkspaces.resolveRootProject(YarnWorkspaces.kt:24)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.Yarn.resolveRootProject(Yarn.kt:27)
    Kotlin
    1.3.50
    r
    • 2
    • 10
  • o

    Ola Gawell

    10/17/2019, 10:22 AM
    I'm using gradle
    5.3.1
    and kodein
    6.3.0
    kotlin
    1.3.40
    s
    • 2
    • 11
  • k

    Kevin Janvier Chinabalire

    10/17/2019, 3:58 PM
    i have an interface with i want to inject . i have bind it inside my
    Application class
    bind() from provider { MyInterface }
    and when i use it inside my reposition NextRepository(prival val view:MyInterface) . I got the below error :
    org.kodein.di.Kodein$NotFoundException: No binding found for bind<MyInterface>() with ?<MyMainClass>().? { ? }
        Registered in this Kodein container:
    Inside my Main Class i have the following :
    val view:MyInterface by instance()
    What am i doing wrong ?
    g
    • 2
    • 1
  • j

    Joan Colmenero

    10/18/2019, 2:50 PM
    I have almost the same question than Kevin I'm using this for my retrofit instance
    bind<MyService>() with singleton {
            instance<Retrofit>().create(MyService::class.java)
        }
    and now I'm wondering if there's a way to avoid doing this
    bind<LogniService>() with singleton {
            instance<Retrofit>().create(LoginService::class.java)
        }
    bind<AuthenticationService>() with singleton {
            instance<Retrofit>().create(AuthenticationService::class.java)
        }
    bind<DetailService>() with singleton {
            instance<Retrofit>().create(DetailService::class.java)
        }
    ---
    s
    • 2
    • 4
  • j

    Joan Colmenero

    10/19/2019, 9:49 AM
    Hi, how would be this with Kodein?
    @Provides
        fun provideLoginApi(api: LoginRetrofitApi): LoginApi = api
    r
    • 2
    • 1
  • j

    Joan Colmenero

    10/19/2019, 11:02 AM
    Because this is the problems [1] that I'm having and I do not know if I'm missing something and I'm not injecting it well or what. [1] : https://stackoverflow.com/questions/58462982/http-method-annotation-is-required-retrofit2
    r
    • 2
    • 3
  • a

    AdrianTodt

    10/23/2019, 1:31 PM
    hi hi sometime ago I created a [add-on library](https://github.com/arudiscord/kodein-jit-bindings) for Kodein that creates instances with reflection and I wanna ask if you guys would like me to PR this add-on to the main repository. the use of this library is to leverage ClassGraph/Reflections classpath scanning to instantiate classes using Kodein mappings.
    r
    • 2
    • 3
  • s

    streetsofboston

    10/25/2019, 5:36 AM
    This'll be hard to overcome.... https://developer.android.com/training/dependency-injection#choosing-right-di-tool
    s
    i
    • 3
    • 3
  • j

    james

    10/30/2019, 12:53 AM
    is there some common mistake that would cause me to see a
    must not override an existing binding
    error? I am seeing
    Binding bind<MyRepository>() with ? { ? } must not override an existing binding.
    , however there's only one place in a single kodein module where this binding is declared. is it possible I'm seeing this because this module is somehow being added twice?
    y
    • 2
    • 2
  • j

    Joan Colmenero

    11/15/2019, 11:14 AM
    Is there any way to create a module(kodein one) and put inside binds of different modules(android ones)? For instance, I have different modules(android ones) on my app, and when I was not using modules (android ones). An example would be : app module (android) inside I can have the DI of Presenter of one feature data module (android) inside I can have the DI of some repositoryImpl When I was not using modules(android ones) I was doing it in the same feature package, but now that I've split the things how can I manage it?
    i
    r
    • 3
    • 3
  • r

    romainbsl

    12/04/2019, 12:27 PM
    Hello fellow Kodeiners, A new version (6.5.0) of Kodein-DI has been plublished! You can find the changelog: https://github.com/Kodein-Framework/Kodein-DI/blob/master/CHANGELOG.md mainly, it contains: - Kotlin
    1.3.61
    - Multi-args factory deprecation, we now recommand to use
    data class
    instead, as one argument. checkout the documentation for examples https://kodein.org/Kodein-DI/?6.5/core#multi-argument-factories
    t
    • 2
    • 2
  • t

    turansky

    12/05/2019, 11:49 PM
    Kodein update allows to reproduce Kotlin/MPP (or Kotlin/JS) bug. After update from
    6.4.1
    to
    6.5.0
    : 1. Kotlin see both versions. 2. Compilation broken - NPE on yarn dependency merge. Single known WA - remove Gradle caches.
    r
    • 2
    • 7
  • k

    krest.mike

    12/06/2019, 1:24 PM
    Kotlin Conf
    🎉 2
    🤘 2
    i
    • 2
    • 1
  • y

    Yardenavirav

    12/24/2019, 4:33 PM
    Nevermind 🙂 ... using version "6.4.0-dev+" and referring to the repository "https://dl.bintray.com/kodein-framework/kodein-dev" worked.
    r
    • 2
    • 9
  • j

    james

    01/06/2020, 1:07 AM
    will Kodein ever have compile time dependency validation (like dagger)? is that even possible with this style of DI, since it's not all generated classes?
    r
    • 2
    • 3
  • a

    agta1991

    01/14/2020, 9:13 PM
    Hi! Does anyone faced issues with StandardScopeRegistry producing InvalidMutabilityException when used in Scopes?
    r
    • 2
    • 13
  • n

    nrobi

    01/22/2020, 9:35 AM
    Does anyone have a working example with kodein on iOS?
    r
    s
    • 3
    • 15
  • a

    Antoine Gagnon

    02/12/2020, 2:43 PM
    Hi! We’re implementing Kodein in our newest app at my company and we’re trying to abstract the dependency injection part (in case we need to suddenly change the DI library in the future) Has anyone ever done this ?
    r
    • 2
    • 2
  • f

    Filipe Uva

    02/18/2020, 7:26 PM
    Hey, my team needs a Kodein tvOS target to develop a certain feature, is this feasible ? https://github.com/Kodein-Framework/Kodein-DI/issues/289
    r
    • 2
    • 15
  • j

    james

    02/24/2020, 4:47 AM
    hey all, I'm hoping someone can help me with something here is there a way to access the binding tag from within the provider block? eg.:
    bind<Retrofit.Builder>(tag = AuthType.OAUTH) with provider {
            Retrofit.Builder()
                .client(instance<OkHttpClient>(tag = /* How do I access the tag used above on provider line? */))
                .addConverterFactory(JsonConverterFactory())
        }
    the use case here is that for some cases, the provider block might be many lines, and I don't want to have to repeat the code for each new
    AuthType
    , so I was wondering can I just pass that through, rather than repeat the code each time. is something like this possible?
    r
    • 2
    • 22
  • m

    Marc Knaup

    03/13/2020, 6:59 AM
    Is there a way to disable automatic polymorphism support?
    interface A
    object B : A
    
    fun main() {
    	val dkodein = Kodein.direct {
    		bind<B>() with instance(B)
    	}
    
    	println(dkodein.instance<A>()) // prints object B()   <--   this should not resolve!
    }
    r
    • 2
    • 4
  • m

    Marc Knaup

    03/13/2020, 7:41 AM
    overrides = null
    and
    overrides = false
    are not documented. From testing, it looks like that •
    true
    requires an override •
    false
    disallows an override •
    null
    disallows an override So this doesn’t seem correct:
    @param overrides Whether this bind **must**, **may** or **must not** override an existing binding.
    I suggest using an enum here for clarity 🙂
    r
    • 2
    • 6
  • m

    Marc Knaup

    03/13/2020, 11:56 AM
    Something I’m missing now and have to write on my own. A scoped builder 🙂
    val kodein = Kodein.scoped(myScope) {
       bind() from singleton { context.createFoo() }
    }
    If there is already a way that would be great! If you think it’s worth adding I’ll open an issue.
    r
    • 2
    • 16
  • m

    Marc Knaup

    03/14/2020, 9:56 AM
    It’s not possible to bind to
    null
    / something nullable? 🤔
    r
    • 2
    • 1
  • m

    Marc Knaup

    03/14/2020, 11:28 AM
    Also, given the provider above I’ve expected the following to retrieve the current instance every time I use the variable
    authentication
    . But it looks like that the result is cached in the delegate (
    AuthenticationHolder.authentication
    can change). Is there any way to tell the delegate to always ask for the current instance from the provider? I don’t want to use
    .provider()
    on the retrieval side to make it a function. That’s supposed to be transparent.
    r
    • 2
    • 2
  • m

    Marc Knaup

    03/25/2020, 4:41 PM
    https://kodein.org/Kodein-DI/?6.5/android#_lifecycle_scope The documentation shows an example that does not compile 🤔 I want exactly one
    ConversationPresenter
    singleton per
    ConversationActivity
    instance.
    • 1
    • 3
  • m

    Marc Knaup

    03/26/2020, 10:45 AM
    val kodein by kodein()
    can be nasty on Android if you forget to import the extension function 😄 https://youtrack.jetbrains.com/issue/KT-37796
    r
    • 2
    • 2
  • n

    Nick

    04/11/2020, 4:36 AM
    Is there a plan to support
    allInstances
    for Javascript at some point?
    val instances: List<Foo> = dkodein.allInstances() // not available in JS
    If not, what are the limitations w/ Kotlin JS that prevent it? Also, is there a good recommended work-around to get similar functionality by using the container directly?
    s
    • 2
    • 1
  • a

    Alex

    04/14/2020, 1:05 PM
    Does anyone know how to get an instance while in the Kodein builder context? I’ve tried finding the solution online, but can’t see anything in the docs. eg. The
    configModule
    has a
    bind<Config>() with instance { Config(…) }
    binding. I want to be able to use the instance of
    Config
    in the
    databaseModule
    which was set in the
    configModule
    .
    val kodein = Kodein {
      import(configModule())
      import(databaseModule(instance())
    }
    The
    instance()
    has a compiler-level warning because it can’t use the
    KodeinAware.instance()
    function - is there a different function to use here? cc: @salomonbrys
    s
    • 2
    • 3
  • t

    Tobias

    04/14/2020, 8:20 PM
    Can anyone confirm if 1.3.72 works/does not work with Kodein? We get
    Not enough information to infer type variable T
    when we use
    val foo: Bar by instance()
    . 1.3.71 worked fine for us
    r
    • 2
    • 6
Powered by Linen
Title
t

Tobias

04/14/2020, 8:20 PM
Can anyone confirm if 1.3.72 works/does not work with Kodein? We get
Not enough information to infer type variable T
when we use
val foo: Bar by instance()
. 1.3.71 worked fine for us
val foo by instance<Bar>()
works for us in 1.3.72 though
r

romainbsl

04/15/2020, 12:29 PM
Hi, this is a weird behavior, it could depend on the platform your are targeting, but until today Kodein-DI was not built on top of 1.3.72, this is now the case. This is available under Kodein-DI 6.5.5
t

Tobias

04/15/2020, 1:25 PM
I got an answer from JB in #general . Basically it's a bug
https://kotlinlang.slack.com/archives/C0922A726/p1586950530266900?thread_ts=1586943557.265800&amp;cid=C0922A726
r

romainbsl

04/15/2020, 1:27 PM
Right! thank you for the feedback 👍
t

Tobias

04/16/2020, 4:52 AM
Sorry I didn't update my question immediately when I got the answer in #general. Thanks for Kodein. 😄
View count: 7