https://kotlinlang.org logo
Docs
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
  • j

    Joe

    10/26/2020, 5:26 PM
    I have created a brand new Android application and am trying to add Kodein, but the moment I add it an Activity, I get a weird (and unhelpful) exception when building. My activity:
    class MainActivity() : AppCompatActivity(), DIAware {
        override val di by di()
        
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
        }
    }
    My application:
    class PromptsApplication: Application(), DIAware  {
        override val di by DI.lazy { }
    }
    The exception:
    r
    • 2
    • 5
  • a

    Alec Muffett

    11/01/2020, 8:36 PM
    Seeking perspective: Hi! I'm coming from a world of manually-hacked-up DI in Ruby, Go and Java, and I'm a noob for both Kodein and Kotlin. I am building a tool/service (commandline, eventually maybe Android) and previously I would build a
    AppConfig
    instance — containing references to objects that implement interfaces like
    DB: IDatabase
    , etc — and pass that
    appConfig
    into the constructors that implemented [various interfaces] for my service. All very typical factory-pattern stuff - the (for example)
    appConfig.DB.query()
    methods would then be used by service methods (via a "retrieval"-type approach) and the appConfig reference itself would be blindly passed on to any child-factories which need to be created. But I am learning Kodein and I am messing around with this blog post which suggests making the companion object for
    Foo : IFoo
    into a
    FooFactory
    by declaring a
    companion object { fun create() : IFoo = ... }
    method. With that context, QUESTION: What's the proper Kotlin & Kodein approach to solving the problem of passing an instantiated
    appConfig
    reference into a
    FooFactory
    that is the companion object of
    Foo
    ? In fact, would this be stupid to do? I am trying to avoid endless invocations of
    Foo(appConfig: DI)
    by passing
    appConfig
    into the
    FooFactory
    when I create the
    FooFactory
    , I could maybe declare
    Foo.appConfig
    as a
    lateinit
    var in the
    Foo
    factory/companion-object, and then set it via a static method call, but I feel sure that there must be a better, more typical way in Kodein - possibly modules?
    s
    • 2
    • 9
  • m

    Merseyside

    11/02/2020, 9:58 AM
    When i try to build my lib with ci error says that core isn't compatible with latest kotlin's version
    s
    r
    • 3
    • 2
  • a

    Alec Muffett

    11/03/2020, 7:48 AM
    Quick Question: if I am implementing an extension method for a Java class, what's the best practice for pushing DI/Kodein into the extension method? There's some behaviour configuration which I want to be able to vary in tests, but I don't have a clear factory pattern to work with because extension methods are resolved statically.
    s
    • 2
    • 1
  • j

    Joost Klitsie

    11/03/2020, 11:44 AM
    Hi guys, does Kodein 7.2.0-master-95 have the IR compiler enabled? I see from the kodein gradle plugin that from 5.0 both legacy and IR are enabled, is this correct?
    r
    • 2
    • 2
  • j

    jmfayard

    11/03/2020, 8:53 PM
    I am adding Kodein-DB to the Kotlin Libraries Playground. Any feedback? https://github.com/LouisCAD/kotlin-libraries-playground/pull/87/files
    👏 3
    r
    • 2
    • 1
  • m

    Marek Defeciński

    11/04/2020, 9:11 AM
    I think TT was removed in 7.x what would be the substitute ?
    r
    • 2
    • 5
  • z

    zalewski.se

    11/05/2020, 3:08 AM
    Is it possible to load/add DI.Module dynamically to the graph(container?)? Let’s say I already have DI instance and I would like to load/add some additional dependencies to it. Before I was using Koin and there is a function on Koin instance to
    loadModule/unloadModule
    , what’s the Kodein way for it? 🙂
    s
    • 2
    • 2
  • z

    zalewski.se

    11/05/2020, 11:53 AM
    Another thing is, how do you set DI for tests? With Koin before every test we start the whole DI where it prepare all modules and after the test we close it. How about Kodein? Is there any way to clean the graph between tests?
    s
    • 2
    • 1
  • a

    Alec Muffett

    11/06/2020, 2:00 PM
    @salomonbrys: There seems to be a website issue: https://docs.kodein.org/kodein-di/7.1.0/index.html -> Page Not Found The page you’re looking for does not exist. It may have been moved. If you arrived on this page by clicking on a link, please notify the owner of the site that the link is broken. If you typed the URL of this page manually, please double check that you entered the address correctly.
    s
    r
    • 3
    • 6
  • m

    Mohsen

    11/13/2020, 4:42 PM
    Hello Kodein. I hope all is well and that you and your family are safe & healthy during this time. I'm learning Kodein now, and writing a test project with it, for an excellent job interview. Since the last day, I had an error, not solved yet. This is the error: org.kodein.di.Kodein$NotFoundException: No binding found for bind<ForecastRepositoryImpl>() with ?<ForecastFragment>().? { ? } Could you please help me with this? Taking this job is vital to me. Thanks a lot.
    j
    r
    • 3
    • 25
  • j

    jeggy

    11/21/2020, 9:04 PM
    Is it possible to stop kodein to print out the whole tree of type options out there? This list is becoming ridiculously long, as I have multiple houndreds dependencies.
    s
    • 2
    • 1
  • s

    Slackbot

    11/25/2020, 1:54 AM
    This message was deleted.
    a
    • 2
    • 1
  • j

    John O'Reilly

    11/25/2020, 5:27 PM
    Just updating to kodein-db 0.4.0 and getting some errors....
    r
    • 2
    • 9
  • s

    salomonbrys

    11/26/2020, 5:28 PM
    Hi everyone. Are there Stack Overflow aficionados here? I'd like this edit to be approved, since the meaning of "Kodein" has changed a lot since @apatrida's initial creation of the tag. If you could review and approve the edit (only of course if you actually do), that would be really helpful! https://stackoverflow.com/review/suggested-edits/27546214
    e
    r
    • 3
    • 2
  • s

    salomonbrys

    11/27/2020, 5:12 PM
    Hey guys. I am wondering if you or anyone you know is using Kodein-DI-Framework-TornadoFX. TornadoFX code base has not seen any code commit since April 16, the last published version dates to January 31 and it still uses Kotlin 1.3.61. Furthermore, I suppose Jetbrains Compose will probably gain more traction in the desktop space. I am therefore wondering if it makes sense for us to maintain Kodein-DI-Framework-TornadoFX. Any feedback regarding TornadoFX would be appreciated 😄
    h
    c
    e
    • 4
    • 3
  • s

    Sergio Casero

    12/04/2020, 1:13 PM
    Hello guys, someone has experience with dexguard and kodein??
    • 1
    • 2
  • a

    Alfred Lopez

    12/13/2020, 9:52 PM
    I'm trying to inject instances of an interface using the class name a la Class.forName(...).newInstance()... I understand that you can do something like...
    val kodeinContainer = DI {
    bind<MyInterface>(tag = "com.dude.MyInterfaceImpl1") with provider {MyInterfaceImpl1()}
    bind<MyInterface>(tag = "com.dude.MyInterfaceImpl2") with provider {MyInterfaceImpl2()}
    }
    but can you do this dynamically? For example, like....
    object MyInjector {
    val kodeinContainer = DI {}
    }
    fun main() {
    MyInnjector.kodeinContainer.bind<...>(...) ...
    }
    s
    • 2
    • 2
  • n

    nimrod

    12/16/2020, 2:48 PM
    Hi, could someone please share a complete example how to use scopes? What I’m trying to do: I have a singleton which needs to be recreated when the server environment is changed from Test to Prod via the debug menu. I figured I should use scopes for that, but the documentation doesn’t have a complete working example that is easy to follow.
    s
    • 2
    • 15
  • j

    John O'Reilly

    12/22/2020, 9:12 AM
    Was 0.4.1-beta version of Kodein DB published anywhere....am not seeing it for example at https://dl.bintray.com/kodein-framework/Kodein-DB/org/kodein/db/kodein-db-serializer-kotlinx/
    r
    • 2
    • 1
  • n

    Nick

    12/23/2020, 6:27 PM
    Is anyone running into this issue (https://youtrack.jetbrains.com/issue/KT-39225) using 7.0.0 or 7.1.0?
    r
    • 2
    • 4
  • r

    romainbsl

    12/28/2020, 10:41 AM
    https://twitter.com/KodeinKoders/status/1343507240020570112
    🎉 3
    i
    • 2
    • 4
  • y

    Yaroslav Nesterov

    12/31/2020, 5:35 PM
    Iuse kodein-db in my android project. kodein_db = "0.4.0-beta"
    implementation("org.kodein.db:kodein-db-jvm:$kodein_db")
    implementation("org.kodein.db:kodein-db-serializer-kotlinx:$kodein_db")
    implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:$kodein_db")
    leads to 
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/kodein/db/leveldb/jvm/LevelDBJvm
    implementation("org.kodein.db:kodein-db:$kodein_db")
    implementation("org.kodein.db:kodein-db-jvm:$kodein_db")
    implementation("org.kodein.db:kodein-db-serializer-kotlinx:$kodein_db")
    implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:$kodein_db")
    leads to 
    Duplicate class org.kodein.db.impl.AbstractDBFactory found in modules jetified-kodein-db-debug-runtime (org.kodein.db:kodein-db-android-debug:0.4.0-beta) and jetified-kodein-db-jvm-0.4.0-beta (org.kodein.db:kodein-db-jvm:0.4.0-beta)
     for 99 classes
    implementation("org.kodein.db:kodein-db:$kodein_db")
    implementation("org.kodein.db:kodein-db-serializer-kotlinx:$kodein_db")
    implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:$kodein_db")
    leads to 
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/my.app.debug-PdUtRd44w96MN7OUXipZlg==/base.apk"],nativeLibraryDirectories=[/data/app/my.app.debug-PdUtRd44w96MN7OUXipZlg==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libkodein-leveldb-jni.so"
    what am I doing wrong? is the use of 
    kts
     mandatory? I still have the 
    build.gradle
    doc: https://docs.kodein.org/kodein-db/0.4/core/install.html
    r
    • 2
    • 2
  • i

    ianbrandt

    01/06/2021, 12:09 AM
    The documentation link in the current GitHub README is 404'ing for me. Anyone else?
    r
    • 2
    • 2
  • a

    Anthony f

    01/07/2021, 2:57 PM
    Hello, does the note for the Direct binding is still valid, as the linked issue is closed ! https://docs.kodein.org/kodein-di/7.2/core/bindings.html#_direct_binding
    r
    • 2
    • 1
  • s

    salomonbrys

    01/08/2021, 4:34 PM
    Hey guys, we've just released Kodein-DB 0.5.0! The changelog: https://github.com/Kodein-Framework/Kodein-DB/releases/tag/0.5.0-beta The documentation: https://docs.kodein.org/kodein-db/0.5/ As is usual for beta versions, this release brings some breaking changes (all documented in the changelog of course). The most important is the fact that
    indexSet
    no longer exists as
    Set<Index>
    has been replaced by
    Map<String, Any>
    . Simply replace
    indexSet
    with
    mapOf
    and you should be good to go! Please let me know if there's anything we can do to help 🙂. We are very interested in feedback for Kodein-DB beta!
    :party-parrot: 1
    🚀 1
    👍 1
    j
    r
    • 3
    • 2
  • m

    Marek Defeciński

    01/11/2021, 6:48 AM
    https://docs.kodein.org/kodein-di/7.2/framework/android.html#_component_based_sub_di I am trying to use subDI to create activity scoped component
    override val di: DI by subDI(di()) {
    Type mismatch. Required: DI Found: DIPropertyDelegateProvider<Any?>
    r
    • 2
    • 17
  • i

    ian.shaun.thomas

    02/03/2021, 7:07 PM
    with this news, when do you think kodein will be migrated to a new long term repository solution? https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
    r
    • 2
    • 1
  • j

    Joost Klitsie

    02/04/2021, 4:17 PM
    Kotlin 1.4.30 is OUT 😄 Will there be an option soon to compile for IR with Javascript? 🙂
    r
    • 2
    • 1
  • r

    romainbsl

    02/05/2021, 4:08 PM
    Hi folks! Kodein-DI 7.3.0 is out! This mostly brings kotlin 1.4.30, with JS IR backend 🙂 (still on Jcenter, this could be the last release with Bintray...)
    🔥 3
    👀 1
    b
    j
    • 3
    • 6
Powered by Linen
Title
r

romainbsl

02/05/2021, 4:08 PM
Hi folks! Kodein-DI 7.3.0 is out! This mostly brings kotlin 1.4.30, with JS IR backend 🙂 (still on Jcenter, this could be the last release with Bintray...)
🔥 3
👀 1
b

Big Chungus

02/06/2021, 6:34 PM
Getting the following when trying to build with IR & 7.3.0
Could not determine the dependencies of task ':app:jsPackageJson'.
> Could not resolve all dependencies for configuration ':app:jsNpm'.
   > Could not resolve org.kodein.di:kodein-di:{require 7.3.0; reject _}.
     Required by:
         project :app
      > No matching variant of org.kodein.di:kodein-di:7.3.0 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but:
Looks like something did not publish right
r

romainbsl

02/08/2021, 8:23 AM
Indeed, I forgot something in the project configuration... 7.3.1 should work https://dl.bintray.com/kodein-framework/Kodein-DI/org/kodein/di/kodein-di-js/7.3.1/
:kotlin-intensifies: 1
j

Joost Klitsie

02/08/2021, 9:56 PM
7.3.1 + IR works like a charm!
🎉 2
r

romainbsl

02/16/2021, 4:29 PM
are you experiencing something like https://github.com/Kodein-Framework/Kodein-DI/issues/355 ?
j

Joost Klitsie

02/16/2021, 5:40 PM
I do not experience such issues (luckily :) ) how is that project setup? Perhaps gradle issue? Maybe needs to clean/invalidate caches
r

romainbsl

02/16/2021, 7:32 PM
Yep this was my first thought, but I was wondering if it was ok for you first 😉 Thx for the feedback
View count: 3