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

    tapchicoma

    10/25/2018, 7:59 PM
    either pass them as param or add them to same module, or provide them in upper module namespace
    g
    • 2
    • 1
  • s

    sloydev

    10/26/2018, 11:17 AM
    Hi there. I'm having some serious performance issues with Koin on Android. When I open a new activity the main thread freezes for about 7 seconds while resolving injections. Has anyone seen something similar?
    s
    a
    c
    • 4
    • 24
  • a

    amatkivskiy

    10/29/2018, 2:06 PM
    can I pass properties to it?
    a
    • 2
    • 2
  • m

    mkporwit

    10/30/2018, 1:10 AM
    To take the example in https://insert-koin.io/docs/1.0/documentation/koin-core/index.html#_binding_additional_type, if I had the following:
    // Service interface
    interface Service{
        fun doSomething()
    }
    
    // OtherService interface
    interface OtherService {
       fun doOtherThing()
    }
    
    // Service Implementation
    class ServiceImp() : Service, OtherService {
        fun doSomething() { ... }
        fun doOtherThing() { ... } 
    }
    How could I write my module definition such that the
    single
    ServiceImpl
    is bound to both
    Service
    and
    OtherService
    ?
    a
    • 2
    • 5
  • a

    amatkivskiy

    10/30/2018, 4:16 AM
    @arnaud.giuliani can you please help me with question about dependencies: as I understood every dependency that can be requested from Koin should be explicitly defined in Koin definition? Meaning there is no implicit constructor injection like it is in Dagger?
    t
    • 2
    • 2
  • o

    o.semen

    10/31/2018, 2:37 PM
    hi, I’m new to koin, this is my first attempt to set it up. but it does not work. my dependencies are wery simple:
    class PWApp: Application() {
    
        private val appModule = module {
            single<AuthRepository> { SecureAuthRepository(get()) }
        }
    
        override fun onCreate() {
            super.onCreate()
            Stetho.initializeWithDefaults(this)
            startKoin(this, listOf(appModule))
        }
    }
    but it can not resolve reference for
    join()
    . Android Studio does not suggest any imports so I looked up examples and copy/pasted imporr from there:
    import org.koin.android.ext.android.inject
    But this method does not suits my case:
    Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
    public inline fun <reified T : Any> ComponentCallbacks.inject(name: String = ..., scope: Scope? = ..., noinline parameters: ParameterDefinition /* = () -> ParameterList */ = ...): Lazy<AuthRepository> defined in org.koin.android.ext.android
    I have no idea what to try next. Could someone please help me with this ?
    t
    • 2
    • 4
  • l

    liminal

    11/01/2018, 3:40 PM
    Hi all, new Koin on Android user here. In Dagger, I would create a Singleton AppComponent Room Database which I would prepopulate in
    .addCallback(object : RoomDatabase.Callback() { override fun onCreate(db: SupportSQLiteDatabase) ... }
    . So by the time I needed to use the data inserted, it was there. With Koin, my DB is declared as a
    bean
    and it gets created lazily so first time I access the database, 0 items is returned, coming back to that screen again renders all of the items. I tried initializing the DB in my Application.onCreate() but the the database's onCreate() does not get called. Any ideas what can be done? My thinking is I need to somehow create the database and its data before it's first accessed (as opposed to how Koin is designed to access dependencies lazily when they are needed by that particular screen). I doubt this part is relevant but I use Google Arch Paging component to load data.
    d
    • 2
    • 12
  • s

    Soundlicious

    11/03/2018, 11:00 AM
    Hello, New on Koin, it's reallyan amazing tool to work with, compare to the complexity of gradle. Love it so far. But, while trying to work on unit test, i've end up with the following problem. My viewModel can't be created and the error message is just "nul" so... i'm a bit lost on how to solve it 😕 Here my repo https://github.com/soundlicious/RatLab for cloning.
    StackTrace.kt
    • 1
    • 1
  • a

    arnaud.giuliani

    11/07/2018, 8:25 AM
    @cristiangm I’m on it 👍
    c
    • 2
    • 1
  • a

    arnaud.giuliani

    11/07/2018, 8:26 AM
    I will need people to help test it also
    t
    s
    • 3
    • 34
  • a

    arnaud.giuliani

    11/09/2018, 8:58 AM
    Koin
    1.0.2
    published 🚀 - changes available here: https://github.com/InsertKoinIO/koin/blob/master/CHANGELOG.md
    👍 6
    j
    i
    • 3
    • 4
  • a

    arnaud.giuliani

    11/09/2018, 3:08 PM
    @Vinicius Volpe one of the next subject is kotlin compiler plugin to help generate module with @Single @Factory or @Scope
    c
    • 2
    • 1
  • a

    Allan Wang

    11/11/2018, 7:32 AM
    So like in gradle, say module A had all the tests and injections written. module B would be able to add its modules and then run all the tests without copy pasting everything
    t
    • 2
    • 3
  • b

    Benoit Duffez

    11/13/2018, 5:35 AM
    Hi, is it possible to use the experimental builder with an injection parameter?
    a
    • 2
    • 3
  • r

    ritesh

    11/13/2018, 8:06 AM
    ?
    a
    t
    • 3
    • 2
  • r

    ritesh

    11/13/2018, 11:45 AM
    fun <T : ViewModel> Fragment.sharedViewModelByClass( clazz: KClass<T>, key: String? = null, name: String? = null, from: ViewModelStoreOwnerDefinition = { activity!! }, parameters: ParameterDefinition = emptyParameterDefinition() ) = viewModelByClass(clazz, key, name, from, parameters)
    m
    • 2
    • 6
  • t

    twisterrob

    11/14/2018, 11:38 AM
    @arnaud.giuliani is the website out of date? There are some typos that were fixed 2 months ago, but not yet on the website.
    a
    p
    • 3
    • 4
  • m

    Markchous

    11/14/2018, 3:54 PM
    That's what I'm trying to do now with gradle. No luck so far.
    j
    • 2
    • 1
  • a

    arnaud.giuliani

    11/15/2018, 3:24 PM
    https://github.com/InsertKoinIO/koin/issues/293
    m
    • 2
    • 1
  • w

    william

    11/23/2018, 9:25 PM
    what does koin android do on top of regular koin?
    a
    • 2
    • 1
  • a

    arnaud.giuliani

    11/24/2018, 10:01 AM
    https://github.com/InsertKoinIO/koin/issues/298
    j
    • 2
    • 6
  • a

    arnaud.giuliani

    11/26/2018, 8:04 AM
    @Alan Evans Same API but koin-core has been entirely rewritten
    a
    • 2
    • 1
  • a

    Alice

    11/26/2018, 1:25 PM
    Does anyone have any examples of using Koin to inject an exposed Database instance? or would that be a misuse? Decided to try kotlin (coming from scala, etc) yesterday and can't figure out how to use this library.
    r
    a
    • 3
    • 11
  • a

    arnaud.giuliani

    11/27/2018, 8:38 AM
    DSL For declaring your Koin application, deprecated API drop, stabilize Scope & Testing API
    p
    • 2
    • 5
  • s

    smassive

    11/28/2018, 11:00 AM
    Hi! We’ve just added Koin to our project and we are facing the test part. We’d like to substitute a provided dependency with a mock in an android test. How should we do it?
    j
    • 2
    • 4
  • s

    sanogueralorenzo

    11/30/2018, 1:32 PM
    will switch to version 2 probably today so yes 😄 just wanted to get some ideas on what would be the best approach on this when your app module doesn't know about the dynamic module
    a
    • 2
    • 2
  • s

    Sergio Crespo Toubes

    12/02/2018, 8:35 PM
    Hello guys. How can i inject the activity view to the presenter? i have found only this solution on internet
    presenter.attachView(this)
    • 1
    • 1
  • a

    arnaud.giuliani

    12/17/2018, 8:02 AM
    nop, Koin doesn’t do any reflection to guess your dependencies. Koin deals with your declared types
    ☹️ 1
    e
    • 2
    • 4
  • n

    nwh

    12/20/2018, 7:24 PM
    What would be the cause of this error?
    Can't access ViewModels from detached fragment
    EDIT: I fixed it by using
    by viewModel()
    instead of
    = getViewModel()
    d
    • 2
    • 1
  • w

    widar

    12/24/2018, 8:12 AM
    Happy Holidays people! I've run into some problems while writing tests with Robolectric. The first test case passes but when running more than one I get
    org.koin.error.AlreadyStartedException: Koin has already been started!
    Has anyone seen this before? 🙂
    m
    j
    • 3
    • 6
Powered by Linen
Title
w

widar

12/24/2018, 8:12 AM
Happy Holidays people! I've run into some problems while writing tests with Robolectric. The first test case passes but when running more than one I get
org.koin.error.AlreadyStartedException: Koin has already been started!
Has anyone seen this before? 🙂
Update: I upgraded Koin and now I get
org.koin.error.BeanOverrideException: Try to override definition with Single [name='SomethingProvider',class='some.SomethingProvider'], but override is not allowed. Use 'override' option in your definition or module.
I overrode
onTerminate()
in my Application class and call
stopKoin()
from there. It seems to work fine! I hope this is a somewhat acceptable way of doing it
m

mgrzechocinski

12/25/2018, 5:16 PM
It is not. https://developer.android.com/reference/android/app/Application.html#onTerminate()
w

widar

12/30/2018, 3:26 PM
Thank you @mgrzechocinski for your help and constructive suggestions on what to do better
Anyway, I read the docs and I it seems good to me since it's only in "emulated process environments" I'm having trouble
j

Johannes Waltsgott

01/02/2019, 10:41 AM
are your test classes extending
AutoCloseKoinTest
?
View count: 2