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

    Va Fu

    11/26/2017, 12:08 AM
    Hello. I need some explanation on "how to do hierarchy" in koin e.g. I need differently created retrofit instances for different activities. I can do it by calling startKoin with all modules needed at each activity, that's seems to be ok but I have, for example, a DB manager, that must be application-scoped. by calling startKoin each time i need to provide new instance of DBModule and that's seems not to be OK, 'cause of new instances are about to create in new context. using dagger I could have activity component is somehow related to the main component. how could I achieve the same using koin? btw, still I love this library so far, ty ❤️
    ☝️ 1
    a
    • 2
    • 7
  • v

    Va Fu

    11/26/2017, 6:40 PM
    just implement KoinComponent in your class and you'll have inject()
    👍 1
    p
    • 2
    • 1
  • d

    Diefferson

    12/20/2017, 12:59 PM
    I created an MVVM structure using ViewModelProvider.Factory with Koin, what do you think? https://github.com/diefferson/koinExample
    d
    a
    • 3
    • 9
  • h

    hoang

    12/31/2017, 10:40 AM
    hello, can somebody point me to a comparison between #koin and #kodein ? I'm kind of lost as it's been a while since I last touch kotlin. Thank you
    a
    • 2
    • 3
  • a

    arnaud.giuliani

    01/08/2018, 8:59 AM
    Hello @Breno you can have a lateinit var property, that you can set after you have injected it in your Activity
    b
    • 2
    • 1
  • t

    themishkun

    02/23/2018, 7:56 AM
    Hello guys, in our team we're tired of dagger 2 on android, that "rebuild all the things" and "wow much boilerplate, so verbose" stuff. I like koin it seems nice to me, but how can I do java interop with it? Any tips?
    l
    a
    • 3
    • 17
  • e

    elifarley

    02/25/2018, 12:04 PM
    Hi, I'm evaluating both Koin and Kodein, and I'd like to know if Koin has something similar to the
    Multiton
    option in Kodein. Also, does it allow you to have other ways of providing dependencies like refSingleton(softReference) or eagerSingleton ? Thanks!
    a
    • 2
    • 3
  • e

    elifarley

    02/26/2018, 10:00 PM
    I'm experiencing a weird exception which I couldn't fix:
    Can't create bean Bean[class=connectors.PanthroClient] due to error: Cyclic dependency detected while resolving class kotlin.Function1
    . Any hints off the top of your heads?
    a
    • 2
    • 4
  • r

    rellenberger

    03/02/2018, 10:53 PM
    Does koin support multiplatform projects?
    a
    • 2
    • 1
  • m

    mgrzechocinski

    03/12/2018, 8:14 AM
    AFAIK, I can use
    get()
    to inject one implementation. Frankly, I haven’t yet tried to use
    get()
    when there are >1 interface implementations in the graph
    a
    • 2
    • 2
  • a

    arnaud.giuliani

    04/17/2018, 5:13 PM
    Here is the last release note for Koin 0.9.2 - https://medium.com/koin-developers/koin-0-9-2-maintenance-fixes-new-branding-roadmap-for-1-0-0-some-other-nice-announces-94f14648e4ad
    m
    • 2
    • 2
  • c

    cristiangm

    04/21/2018, 3:36 PM
    I mean, I'm used to DaggerMock which is a wonderful tool and I would like to be able to introduce mocks on UI Tests to not depend on third party services ( for my own services I mostly use WireMock )
    d
    a
    • 3
    • 10
  • d

    dpreussler

    04/21/2018, 5:23 PM
    hey, i am a bit lost. How you you open a second scope with koin? For android an activity scope for example, something that will be closed again.
    d
    • 2
    • 2
  • r

    realsoc

    04/30/2018, 7:15 PM
    Can't find a way to declare this as a factory in my Module 😣 Thanks for your help !!
    a
    • 2
    • 4
  • a

    andre.artus

    05/06/2018, 12:53 AM
    Hi, how do I inject a value into a property that's part of a POJO/POKO or otherwise in a class that does not inherit from ComponentCallbacks (as required by org.koin.android.ext.android.inject)? I have a class that requires a parameter-less constructor and does not implement ComponentCallbacks. It's part of an Android app (17+) written in Kotlin(1.2.41) using Koin (0.9.2). I want to inject my repo into this [non-conforming] class.
    a
    • 2
    • 2
  • a

    arnaud.giuliani

    05/11/2018, 6:59 AM
    Hello @cristiangm I've also seen the news from Google IO. AndroidX is in alpha-1
    c
    • 2
    • 6
  • a

    AntoineJojo

    05/14/2018, 3:53 PM
    Hi! Have you already encountered a NoBeanDefFoundException when launching multiple Instrumented tests? In my case launching test methods one by one works, but launching test class produces this error for second test method.
    a
    • 2
    • 3
  • c

    cketti

    05/17/2018, 11:32 AM
    // In the Activity
    val viewModel: MyViewModel by viewModel(parameters = { mapOf("itemId" to R.id.whatever) })
    
    // In the Koin module
    viewModel { MyViewModel(get<MyRepo>(), it.values["itemId"] as Int) }
    👍 2
  • a

    andre.artus

    05/29/2018, 4:18 AM
    I'm using the method proposed by @cketti in my project now, but I'm having some problems with a shared viewmodel. In my setup itemId is read in the master fragment from the arguments passed to it.
    model = getViewModel(parameters = { mapOf("itemId" to itemId) })
    I'm sharing the viewmodel with the detail fragment so that (in theory) it only needs to load once. I tried
    model = getSharedViewModel()
    But it fails with:
    Caused by: org.koin.error.BeanInstanceCreationException: Can't create bean Factory[class=za.co.ruggedmobile.petermetertest.ui.meters.MetersViewModel, binds~(android.arch.lifecycle.ViewModel)] due to error :
        	kotlin.TypeCastException: null cannot be cast to non-null type <http://kotlin.Int|kotlin.Int>
    a
    • 2
    • 17
  • a

    arnaud.giuliani

    06/13/2018, 7:56 AM
    Hello @jordan29.04.1197, what do you use in Dagger 2? You can smoothly migrate to Koin, by group of components
    j
    • 2
    • 1
  • b

    Bernardo Ferrari

    06/18/2018, 6:00 PM
    It is internally kind of inspired by the popular mvvm todo sample from Google. Problem is, I'm accessing Files on the LocalDataSource, to access Files I need the Context, if I need the Context it shouldn't be passed as a parameter (or might leak, since localDataStorage is a singleton), and Application.instance is a not a very good solution. Some people on Reddit told me to user Dagger (a bit overkill of this) or Koin, which is exactly what I am trying, but I have absolutely no idea how to proceed. Could someone shine some light for me?
    a
    • 2
    • 2
  • a

    arnaud.giuliani

    06/19/2018, 8:34 AM
    Hello @tapchicoma, have you a sample to share?
    t
    • 2
    • 5
  • a

    arnaud.giuliani

    06/23/2018, 8:07 AM
    We are also preparing beta access to koin 1.0.0
    👍 1
    t
    • 2
    • 3
  • a

    arnaud.giuliani

    07/02/2018, 9:22 AM
    you will have a static
    inject()
    and
    get()
    function to help you inject instances
    k
    • 2
    • 5
  • t

    tapchicoma

    07/11/2018, 7:44 AM
    For example, in dagger
    OkHttpClient
    declared in base network module, then in new koin modules that requires this client it will be imported from dagger. Eventually only base dependencies will be imported from dagger and then they can be moved in Koin. I think such approach should work.
    j
    • 2
    • 3
  • m

    mgrzechocinski

    07/13/2018, 7:11 PM
    ah, ok. As described here (https://medium.com/koin-developers/opening-the-koin-1-0-0-beta-version-99cb8be1c308):
    The dependency injection API has been reviewed to allow you to use destructured declaration directly, without forcing you to use a Map of value
    Seems like I missed paranthesis in lambda arg. This compiles:
    factory { (activity: FragmentActivity) -> PermissionManager(activity) }
    @arnaud.giuliani Isn’t it missing in the docs example as well: https://beta.insert-koin.io/docs/1.0/documentation/reference/index.html#_injection_parameters?
    val myModule = module {
        single{ view : View -> Presenter(view) } // should be: single{ (view : View) -> Presenter(view) }
    }
    a
    • 2
    • 2
  • t

    tapchicoma

    07/18/2018, 6:14 PM
    from what I see
    releaseContext()
    not actually removes module, but rather drops all
    single {}
    instances
    a
    • 2
    • 8
  • b

    bachhuberdesign

    07/24/2018, 1:56 PM
    Stupid question but I didn’t see it in the docs: is there a way I can easily disable Koin debug log output? Or do I need to override AndroidLogger with an empty
    debug()
    function?
    t
    • 2
    • 2
  • a

    arnaud.giuliani

    08/06/2018, 6:29 AM
    We'll be working on beta until september to release the stable
    👍 2
    m
    • 2
    • 1
  • a

    arnaud.giuliani

    08/09/2018, 12:52 PM
    https://github.com/InsertKoinIO/koin/issues/79#issuecomment-410486256
    f
    • 2
    • 3
Powered by Linen
Title
a

arnaud.giuliani

08/09/2018, 12:52 PM
https://github.com/InsertKoinIO/koin/issues/79#issuecomment-410486256
f

Farzad

08/09/2018, 2:53 PM
Yeah I added the
closeKoin()
function call before starting it and moved it from
main()
to
Application.module()
and it works
Thanks!
a

arnaud.giuliani

08/10/2018, 6:45 AM
👍
View count: 1