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
  • r

    romainbsl

    04/15/2020, 12:30 PM
    Hello friends, A new version (6.5.5) of Kodein-DI has been plublished! You can find the changelog: https://github.com/Kodein-Framework/Kodein-DI/blob/6.5/CHANGELOG.md It brings Kotlin 1.3.72 !
    👍 3
    n
    2 replies · 2 participants
  • j

    james

    04/16/2020, 12:42 AM
    I have an old singleton class which was used in about 20 other classes, previously via
    MyClass.getInstance()
    .. I've now converted this to a Kodein singleton, however I'm wondering if there's still a way I can access it from one particular class without
    @Inject
    ? there's one particular class I don't really want to update because it is intertwined with a lot of other stuff and in the interest of time (and testing capacity) I would like to leave that class mostly untouched. so most of the classes now just get
    MyClass
    injected to them, but is there some way I can retrieve it from the other class I mentioned which I'd like to avoid making large changes to?
    t
    1 reply · 2 participants
  • s

    sherry.yuan

    04/21/2020, 12:25 AM
    👋 Just started learning Kodein. If I have 2 modules and
    module B
    needs to use an instance from
    module A
    is the best practice to import
    module A
    into
    module B
    ? For example,
    subscribersModule
    needs the retrofit instance from `networkingModule`:
    val networkingModule = Kodein.Module("networking") {
        bind<Retrofit>() with singleton {
            Retrofit.Builder()
                .baseUrl("<https://api.example.com/>")
                .build()
        }
    }
    val subscribersModule = Kodein.Module("subscribersModule") {
    
        import(networkingModule)
    
        bind<SubscribersService>() with singleton {
            instance<Retrofit>().create(SubscribersService::class.java)
        }
    }
    r
    3 replies · 2 participants
  • p

    Pavel Arkhipov

    04/27/2020, 2:50 PM
    Hi all, I tried many approaches but they don’t work. I try to write simple code with KodeIn and I get:
    Unable to instantiate activity ComponentInfo{uptop.me.testcoroutine/uptop.me.testcoroutine.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
    Activity code:
    class MainActivity : AppCompatActivity(), KodeinAware {
    
        override val kodein by closestKodein(context = this)
    
        private val viewModel: MainViewModel by kodein.instance<MainViewModelImpl>()
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
            viewModel.doSomething()
        }
    
    }
    Dependencies:
    fun appModule(context: Context) = Kodein.Module("appModule") {
        bind<MainInteractor>() with provider { MainInteractorImpl() }
        bind<MainViewModel>() with provider { MainViewModelImpl(instance()) }
    }
    App:
    class App: Application(), KodeinAware {
        override val kodein: Kodein by Kodein.lazy {
            import(androidXModule(this@App))
            import(appModule(this@App))
        }
    }
    Thanks in advance!
    r
    17 replies · 2 participants
  • m

    mlykotom

    04/28/2020, 8:08 AM
    Hey everyone, I would like to implement something like “*user scope*” where particular dependencies can exist only that scope and can be destroyed (app start/login -> logout for user scope). I understand kodein has some concept of
    Context
    and
    Scope
    , but I couldn’t find some good example how to achieve it. Could anyone point me to any article/tutorial/explanation of how to do it? Thank you 🙂
    p
    2 replies · 2 participants
  • n

    Nicolas

    04/29/2020, 11:31 AM
    Hello, I use Android Studio 4.0 Beta 5 with Kotlin 1.3.72 and kodein 6.5.5. I can compile and run my app without issue but Android Studio reports me this error: Not enough information in infer type variable T for this code:
    private val toolbarManager: ToolbarManager by instance() // the underlined error is on instance()
    I can have no error with this code:
    private val toolbarManager by instance<ToolbarManager>()
    A while ago, perhaps before I have upgraded Android Studio and/or Kotlin and/or kodein, the first code didn't raise any error in Android Studio. Does anybody have an explanation ?
    i
    1 reply · 2 participants
  • e

    eygraber

    06/01/2020, 7:17 AM
    Was Kodein 7 released? I see it in GitHub for a while now (as well as commits referencing 7.1) but the artifacts are not in mavenCentral or jcenter
    r
    1 reply · 2 participants
  • e

    eygraber

    06/02/2020, 7:16 PM
    Still appears to be a memory leak issues in Kodein v7 - https://github.com/Kodein-Framework/Kodein-DI/issues/301
    r
    1 reply · 2 participants
  • y

    yshrsmz

    06/09/2020, 11:04 AM
    Hi, In KMP project(Android/iOS), is it safe to assume that I can replace usage of
    Instance(erasedSet())
    with
    instance()
    in Kodein-DI 7.0?
    s
    1 reply · 2 participants
  • j

    Joost Klitsie

    06/15/2020, 3:21 PM
    Update: I have 1 interface that implements multiple interfaces. The implementation of that interface is a singleton. I try to bind the instance to all the different interfaces that it implements. On 6.5.5 this was working fine, on 7.0.0 I get the error mentioned above. Is this worth reporting or am I doing something wrong?
    s
    7 replies · 2 participants
  • m

    Mgj

    07/02/2020, 9:38 AM
    Im trying to use kodein in a multiplatform project that targets android and ios. For android im using https://kodein.org/Kodein-DI/?7.0/android#_using_a_trigger but im getting an error:
    Expression 'di' cannot be invoked as a function. The function 'invoke()' is not found
    - Any ideas? Using kodein 7.0.0
    r
    2 replies · 2 participants
  • m

    Mgj

    07/02/2020, 10:16 AM
    Ok so you have to actually define the bindings directly, fair enough. The docs for 7.0 could use some love i think, https://kodein.org/Kodein-DI/?7.0/getting-started doesnt match the info in https://kodein.org/Kodein-DI/?7.0/migration-6to7 - e.g. its still referencing
    kodein-generic
    and
    kodein-erased
    ➕ 1
    r
    1 reply · 2 participants
  • a

    Alexander Minyaev

    07/21/2020, 6:39 AM
    How to connect dependence to common target in mpp? Now I use for common:
    "org.kodein.di:kodein-di:7.0.0"
    for jvm
    "org.kodein.di:kodein-di-jvm:7.0.0"
    for js
    "org.kodein.di:kodein-di-js:7.0.0"
    I see only for jvm and for js.
    🔥 1
    j
    s
    +1
    7 replies · 4 participants
  • a

    Artem Kopan

    08/21/2020, 8:05 AM
    Hi everyone. I am trying to use kodein in kmp ios project, but I faced with exception EXC_BAD_ACCESS. Did anyone know how to fix it? Version 7.1.0-master87
    s
    2 replies · 2 participants
  • j

    Joost Klitsie

    08/22/2020, 12:43 PM
    Hi all, is the new kodein (7.1.0-master-88) already compiled with the IR compiler for JS (or at least both option)?
    r
    5 replies · 2 participants
  • i

    Ivann Ruiz

    08/31/2020, 4:15 PM
    Hi all 👋 trying to use Kodein for a KMP 1.4 native project (I’ve used it before Kotlin 1.4) but when I add the dependency in
    commonMain
    the iOS dependency doesn't seem to be found...
    implementation("org.kodein.di:kodein-di:7.0.0")
    tried following this post and I'm doing pretty much the same, noth sure if anyone has run into this same problem... thoughts?
    1 reply · 1 participant
  • p

    Peter

    09/22/2020, 5:10 PM
    hi - looking into kodein a bit, does it use reflection or perform code generation?
    r
    3 replies · 2 participants
  • s

    Shawn Witte

    09/26/2020, 2:07 AM
    Hello, I'm trying to set up my multiplatform project with Kodein DI, and I'm wondering if there is a recommended way to create a
    DI
    to provide platform-specific implementations. Basically, I have an
    interface
    in my common code that I have created a platform specific implementation for in JVM (no other platforms yet, since common/jvm is enough for my current level of multiplatform exploration). I originally decided to inject the platform specific code into the constructor without a framework:
    class SomeClass(val commonInterfaceName: CommonInterfaceName)
    and then inject the implementation when I start the app from the JVM entry point. I can do the same thing now by injecting a
    DI
    instead, but I want to be able to create a
    DI
    module that I know contains all of these bindings. I'm wondering if there is a standard way to ensure that the
    DI
    being passed in has all of the necessary bindings (which I guess gets into a broader question of compile-time verification). Or if there is a way to I'm not sure if what I'm saying is clear or not. Also, before you ask why I'm not using
    expect/actual
    , the answer is because I don't know if/when I should. It seemed like interfaces would be more robust and provide for dependency injection (in the way that I was doing it, at least). I'm still trying to work out what multiplatform best practices look like.
    j
    3 replies · 2 participants
  • j

    John O'Reilly

    09/26/2020, 7:22 AM
    are there any sample apps that use that Kodein-DB beta?  I'm trying here to pull in to a (multiplatform) project and having some issues....gradle seems to be able to get dependencies but see following
    +--- org.kodein.db:kodein-db:0.2.0-beta FAILED
    \--- org.kodein.db:kodein-db-serializer-kotlinx:0.2.0-beta
    r
    16 replies · 2 participants
  • j

    John O'Reilly

    09/27/2020, 2:50 PM
    Re.
    kodein-db
    , am calling
    val db = DB.open("bikeshare_db")
    but getting
    org.kodein.db.leveldb.LevelDBException: NotFound: bikeshare_db/LOCK: No such file or directory
    it seemed from https://docs.kodein.org/kodein-db/0.2.0/core/setup-database.html that the default is to create the database if it does not exist?
    r
    17 replies · 2 participants
  • a

    aerialist

    09/29/2020, 4:21 PM
    @romainbsl hi! May be you have some ideas about my problem?
    r
    6 replies · 2 participants
  • j

    John O'Reilly

    09/29/2020, 8:12 PM
    I'm trying out
    kodein-db
    in a kotlin multiplatform project. https://docs.kodein.org/kodein-db/0.2.0/core/operations.html includes examples like
    db.find<User>().all().models()
    I'm not seeing
    models()
    available here for some reason
    s
    6 replies · 2 participants
  • r

    rocketraman

    09/30/2020, 1:45 PM
    Hey guys, I've used kodein on the backend before, but am new to using it on Android/KMP. I have a dependency which needs an
    applicationContext
    to initialize (SQLDelight android SqlDriver). Scopes seem the right way to do that, but I don't see anything like ApplicationScope available.
    r
    2 replies · 2 participants
  • r

    rocketraman

    09/30/2020, 9:28 PM
    Trying to inject into an Android
    Worker
    as per https://stackoverflow.com/questions/59546159/kodein-injecting-into-workmanager -- however, as soon as I extend from
    DIAware
    , I get
    e: java.lang.IllegalStateException: Backend Internal error: Exception during file facade code generation
    at compile time. Any ideas?
    3 replies · 1 participant
  • j

    John O'Reilly

    10/03/2020, 2:28 PM
    kodein-db question....I'm able to do following
    val networkList = cityBikesApi.fetchNetworkList().networks
    networkList.forEach {
        db.put(it)
    }
    but following does not work....should it?
    db.put(networkList)
    r
    1 reply · 2 participants
  • j

    John O'Reilly

    10/03/2020, 2:49 PM
    And somewhat related, is following recommended way to get back a list
    db.find<Network>().all().useModels { it.toList() }
    https://github.com/Kodein-Framework/Kodein-DB includes example of use of
    models()
    but that's not resolving here
    r
    2 replies · 2 participants
  • c

    Christoph Flick

    10/06/2020, 10:07 PM
    Hi 🙂 has anyone experience testing a ktor app using the kodein DI Feature? I've got an application that looks like this:
    fun Application.main() {
        di {
            bind<SomeService>() with singleton { SomeService(environment.config) }
        }
    ...
    I use the service somewhere in the app, in the routes, etc. My tests (kotest) look like that:
    "A Request should do something" {
        withServer {
            val req = handleRequest {
                uri = "/someroute"
            }
    
            req.requestHandled shouldBe true
            req.response shouldHaveStatus HttpStatusCode.OK
        }
    }
    withServer
    is a wrapper for
    withTestApplication({ main() }, test)withTestApplication({ main() }, block)
    My problem is that I currently need to test against a real database as I don't get the DI mock to work. Any hints for me here? Thanks!
    r
    2 replies · 2 participants
  • n

    nrobi

    10/08/2020, 7:30 AM
    Is someone using Kodein-DI with Compose? I’m curious how are you providing and scoping VMs in Composables? @romainbsl is any support planned?
    j
    10 replies · 2 participants
  • t

    Tucker Barbour

    10/23/2020, 7:58 AM
    I’m trying out Kodein in a ktor project. I’ve used Koin previously but was curious to checkout Kodein as I’m looking for a single DI framework to use for other non-ktor Kotlin projects and Kodein has a lot of the features I’m used to from Guice. I’m reading through the docs for the DIController and having some difficulty understanding how all the pieces fit together. The link to the example project is a dead github link (https://github.com/Kodein-Framework/Kodein-DI/tree/7.1/demo/demo-ktor) Are there any Kodein 7.x examples with ktor using the DIControllerFeature?
    r
    1 reply · 2 participants
  • d

    David Hadley

    10/24/2020, 12:33 PM
    Hi, I'm considering using Kodein-DB in a project but I don't see any license in the repository (https://github.com/Kodein-Framework/Kodein-DB). Are there plans to add some kind of open source license to this project?
    r
    2 replies · 2 participants
Powered by Linen
Title
d

David Hadley

10/24/2020, 12:33 PM
Hi, I'm considering using Kodein-DB in a project but I don't see any license in the repository (https://github.com/Kodein-Framework/Kodein-DB). Are there plans to add some kind of open source license to this project?
r

romainbsl

10/24/2020, 3:31 PM
It is open source, licence has been forgotten. We will fix this asap
d

David Hadley

10/24/2020, 3:32 PM
Ah great thanks!
View count: 6