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
koin
  • a

    Anvith

    06/08/2022, 7:22 AM
    How does one handle the following usecase(manual as of now) via koin?
    class F1 : F{
    val b = DepB()
    
    val a = DepA(b)
    val c = DepC(b)
    }
    
    class F2 : F{
    val b = DepB()
    
    val a = DepA(b)
    val c = DepC(b)
    }
    Basically I want factory instances for all except within a particular
    F<x>
    class(i.e F1 or F2) I wish that DepB instance needs to be shared. I want to be able to do this at a super class
    F
    level instead of defining the same scope over and over again for each of the subclasses
    F1
    and
    F2
    .
    a
    • 2
    • 2
  • b

    Bogdan Cordier

    06/08/2022, 10:40 AM
    Hi, i’ve switched to koin 3.2.0 in an Android project and it seems that Gradle is unable to retrieve koin-test-junit4 if in the module config the java targetCompatibility is set to 1.8. Switching the config to java version 11 solves the issue. Is there any particular reason that this dependency now enforces the jvm version ?
    p
    a
    • 3
    • 2
  • a

    ankushg

    06/09/2022, 12:30 AM
    I’ve got a module where I have something like
    class Outer(val middle: Middle?)
    class Middle(val inner: Inner)
    interface Inner
    module {
        factory { Outer(getOrNull()) }
        factoryOf(::Middle)
    }
    Depending on certain conditions, I dynamically provide an implementation of
    Inner
    into the Koin instance. Current Behavior: • when
    Inner
    is dynamically loaded, Koin can inject both
    Middle
    and
    Outer
    . • when
    Inner
    is not dynamically loaded, Koin fails to inject both
    Middle
    and
    Outer
    Desired behavior: • When
    Inner
    is not dynamically loaded and
    Middle
    cannot be injected (because
    Inner
    is missing), I would still like to inject
    Outer
    using
    null
    as the parameter value Does anyone know how to do this? I’m guessing it might be possible with a method that’s similar to
    getOrNull
    ?
    • 1
    • 1
  • u

    Ugurcan Yildirim

    06/13/2022, 8:33 AM
    how can I force the lib to use viewModel instead of factory?
    a
    • 2
    • 12
  • u

    Ugurcan Yildirim

    06/13/2022, 8:56 AM
    besides this issue, recyclerview.adapter classes are not defined in module files:
    m
    • 2
    • 6
  • u

    Ugurcan Yildirim

    06/13/2022, 8:56 AM
    @Factory
    class ****Adapter(private val imageLoader: ImageLoader) :
        RecyclerView.Adapter<****Adapter.ItemViewHolder>()
    • 1
    • 2
  • m

    Mini

    06/13/2022, 10:26 AM
    I want to use koin to create a small library that includes some android UI - for this I would want to inject dependencies into viewmodels used by such UI. (Yes this library will be quite opinionated and not expected for generic reusability) I found this on context isolation, but I’m not sure how to use this with functions such as
    koinViewModel()
    . Any suggestions on how to go about this?
    a
    • 2
    • 3
  • r

    Renaud

    06/13/2022, 4:37 PM
    I’ve got the following error :
    :desktop:jvmMain: Could not resolve io.insert-koin:koin-core:3.2.0.
    It looks like a dependency issue but all my other dependencies look fine. For more context: In
    :common:build.gradle.kts
    sourceSets {
    
        val commonMain by getting {
            dependencies {
    
                ...
    
                // Koin
                api("io.insert-koin:koin-core:3.2.0")
                api("io.insert-koin:koin-android:3.2.0")
    
            }
        }
    My
    settings.gradle.kts
    :
    pluginManagement {
        repositories {
            google()
            gradlePluginPortal()
            mavenCentral()
            maven(url = "<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
            maven(url = "<https://jitpack.io>")
        }
    
        plugins {
            kotlin("multiplatform") version "1.6.10"
            kotlin("android") version "1.6.10"
            kotlin("jvm") version "1.6.10"
            kotlin("plugin.serialization") version "1.6.20"
            id("com.android.application") version "7.0.4"
            id("com.android.library") version "7.0.4"
            id("org.jetbrains.compose") version "1.1.0"
            id("org.jetbrains.dokka") version "1.6.20"
            id("com.github.johnrengelman.shadow") version "7.1.2"
        }
    }
    and my root
    build.gradle.kts
    :
    allprojects {
        repositories {
            google()
            gradlePluginPortal()
            mavenCentral()
            maven(url = "<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
            maven(url = "<https://jitpack.io>")
        }
    }
    
    plugins {
        kotlin("multiplatform") apply false
        kotlin("android") apply false
        kotlin("jvm") apply false
        kotlin("plugin.serialization") apply false
        id("com.android.application") apply false
        id("com.android.library") apply false
        id("org.jetbrains.compose") apply false
        id("org.jetbrains.dokka") apply false
        id("com.github.johnrengelman.shadow") apply false
    }
    I didn’t use
    buildscript
    on purpose.
    s
    a
    • 3
    • 2
  • o

    Orhan Tozan

    06/14/2022, 4:57 PM
    In an Activity, you can use by inject() for getting a dependency at property level. How can I do this if I want to inject something that is tied to a scope?
    a
    • 2
    • 8
  • m

    Mark Malik

    06/15/2022, 8:58 AM
    The test as simple as this:
    "Not allow logging in with incorrect api key" {
                    // given
                    val payload = JsonObject(
                        mapOf(
                            "apikey" to JsonPrimitive("wrong"),
                            "username" to JsonPrimitive("jamma"),
                        )
                    )
                    // when
                    testApplication {
                        application { Application::testModule }
                        environment {
                            config = ApplicationConfig("test-application.conf")
                        }
                        val client = createClient { install(ContentNegotiation) { json() } }
    
                        val response = <http://client.post|client.post>("api/login") {
                            contentType(ContentType.Application.Json)
                            setBody(payload)
                        }
    
                        // then
                        response shouldHaveStatus HttpStatusCode.Unauthorized
                    }
                }
    I’m using KoinExtensions to inject the dependencies.
    override fun extensions(): List<Extension> =
            listOf(KoinExtension(listOf(testDbModule, testHttpModule, RepositoryModule)))
    a
    • 2
    • 9
  • j

    jmfayard

    06/20/2022, 2:15 PM
    Hello world When I run a unit test that does nothing apart from starting and stopping Koin, it takes about 2s to complete. (If there are multiple classes, I pay the penalty only once). I have 12 modules of 5-10 classes each. Are those 2s normal? What can I do to investigate the performance?
    j
    a
    • 3
    • 2
  • l

    Lilly

    06/22/2022, 2:11 PM
    I have a definition which I add at runtime via
    getKoin().declare(MyObject())
    .
    class MyObject(val source: Map<String, Any> = emptyMap())
    Later I redeclare it, but with data:
    getKoin().declare(MyObject(mapOf("key" to value), allowOverride = true))
    My API exposes this object like:
    class Api : KoinComponent {
      val myObject: MyObject by inject()
    }
    but when I access it, I get the old version of the object with empty map. Any ideas? EDIT: When I call
    getKoin().get<DeviceContext>()
    at the position where I want to access the map, I get the correct object, while
    api.myObject
    is another object. I'm wondering how this can be since by inject is lazy, so actually it should grab the recent one
  • m

    Mark Malik

    06/23/2022, 5:44 AM
    Hello Guys, Could anyone assist with my problem? I’m not able to correctly inject dependencies when running the Koin 3.2 and Ktor 2.0.2 app. This is the thread: https://kotlinlang.slack.com/archives/C67HDJZ2N/p1655283266532819 I created a very basic sample project to show the issue. https://github.com/C0deH0use/ktor-koin-injection-issue-sample
  • k

    Kieran Wallbanks

    06/23/2022, 12:02 PM
    Hey all - I've bumped my code to use the new Koin Extended DSL and am running into an issue. Using the old, deprecated DSL I could do
    single<Element>(createdAtStart = true)
    and if this was loaded post-start (i.e. in a later call to
    loadKoinModules
    ) this would init the object immediately. However, using the new DSL with
    singleOf(::Element) { createdAtStart() }
    this is no longer the case. What can I do instead?
  • p

    pitpit

    06/23/2022, 2:13 PM
    Hi I try to use 3.2.0 but in unit test I cannot find KoinTest class (I’ve put the testImplementation “io.insert-koin:koin-test-junit4:3.2.0”) but KoinTest not found
  • a

    Alejandro Rios

    06/23/2022, 4:54 PM
    Hello 👋🏼, I've try to migrate from Koin
    3.1.5
    to
    3.2.0
    , I've changed some declarations from
    single { }
    to
    singleOf()
    and from
    viewModel { }
    to
    viewModelOf()
    but after clean and reun the app I'm getting this error:
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/koin/dsl/ModuleKt;
            at com.metamap.sdk_components.di.AppModuleKt.<clinit>(AppModule.kt:26)
            at com.metamap.sdk_components.di.AppModuleKt.getApplicationModule(AppModule.kt:26)
            at com.metamap.metamap_sdk.SdkStartUpProvider.<init>(SdkStartUpProvider.kt:25)
            at java.lang.Class.newInstance(Native Method)
            at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121)
            at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:67)
            at android.app.ActivityThread.installProvider(ActivityThread.java:6380)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
            at android.app.ActivityThread.access$1100(ActivityThread.java:199)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:6669)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "org.koin.dsl.ModuleKt" on path:
    any idea of what am I missing?
    n
    • 2
    • 4
  • j

    Jay

    06/23/2022, 9:30 PM
    Hello 👋 , documentation here talks about
    MockProviderRule
    but I cannot resolve it in version
    3.1.6
    . Any idea what might be wrong?
    a
    • 2
    • 4
  • n

    Nick

    06/23/2022, 10:47 PM
    When upgrading from 3.1.6 to 3.2.0, I am encountering
    java.lang.IllegalStateException: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Start/end imbalance
    I see this ticket here, I was wondering if anyone has a solution for this? ... Ninja edit: See googles response here
    a
    • 2
    • 5
  • b

    Bao Le Duc

    06/28/2022, 7:41 AM
    Hi, I have a question about scope. How does closing a scope work with JVM garbage collector? Should we always call
    scope.close()
    whenever we don’t need the scope instance? (I’m new to Koin)
    a
    • 2
    • 2
  • s

    Slackbot

    06/30/2022, 10:08 AM
    This message was deleted.
  • d

    deviant

    06/30/2022, 11:09 AM
    hey guys is it possible to have 2 definitions of same type but with different params set?
    scoped<DateResolver> { (r: CurrentReservation) -> DateResolverFactory(r) }
            scoped<DateResolver> { (pd: ProductDetail) -> DateResolverFactory(pd) }
  • p

    Partho Paul

    06/30/2022, 11:11 AM
    Hi, I’ve a use case where my classes are as
    class A(b: B(), c: C())
    
    class B(d: D())
    
    class C()
    I want to write test cases of
    A
    and I did the following:
    class ATest : KoinTest {
    
        @JvmField
        @RegisterExtension
        val koinTestExtension = KoinTestExtension.create {
            val serviceModules = module {
                factory { B(get()) } 
            }
    
            val daoModules = module {
                factory { C() }
            }
    
            val httpClient = module {
                factory { D() }
            }
    
            modules(httpClient, daoModules, serviceModules)
        }
    
        @JvmField
        @RegisterExtension
        val mockProvider = MockProviderExtension.create { clazz ->
            mockkClass(clazz)
        }
    
        @Test
        fun doTest(koin: Koin) = runBlocking {
            declareMock<B> {
                coEvery { something(any()) } returns Either.Right("response")
            }
            declareMock<C> {
                coEvery { fetchDoc(any()) } returns Either.Right(GetItemResponse {
                    item = mapOf("key" to AttributeValue.S("value"))
                })
            }
    
            val a = A(
                b = koin.get<B>(),
                c = koin.get<C>()
            )
    
            val resp = a.doSomething(request)
            assertEquals(resp.isLeft(), false)
    
        }
    }
    Is there a more elegant way of mocking `B`and
    C
    and put them inside
    A
    ?
  • m

    miqbaldc

    07/02/2022, 2:01 AM
    Does
    Koin
    requires compatibility (needs same
    Kotlin
    version) with
    Kotlin
    versions to use? or is it okay to this ways? e.g: using
    Kotlin
    1.6
    , but
    Koin
    already using
    1.7
    a
    • 2
    • 1
  • m

    Marcin Wisniowski

    07/04/2022, 9:24 PM
    It would seem that
    @Single
    classes are ignored by the code generation if they reference
    BuildConfig
    , with no error or warning visible in the build output (other than the inevitable missing dependency when running the app).
    a
    • 2
    • 2
  • l

    Lilly

    07/07/2022, 4:28 PM
    How to handle a scope across multiple koin modules or even gradle modules? Example: I have a screen that utilizes bluetooth api to scan for devices. When connected with a device the user is redirected to a dashboard screen where I want to create a
    scope(named("CONNECTED")) {  }
    . Every definition should live in this scope. But the definitions are spread across multiple gradle modules. Any guidelines for this kind of use case?
    c
    a
    • 3
    • 2
  • m

    Merseyside

    07/15/2022, 9:43 AM
    Hi! I have a case which can't find a way to resolve. I have two "application states" - logged in and logged out. When I logged in I want to load a module with specific instances for example repos, useCases. When I log out - unload them. Some repos needs coroutine scope that must be active only when we logged in. I can't find a way how to close coroutine scope when I need to unload modules. Any suggestions?
    a
    • 2
    • 4
  • m

    Mobile Dev.

    07/16/2022, 11:50 PM
    Hello, i'm using koin with annotations in kmm project. In Android it's okay but in ios there is a problem i couldn't fix it. When i open a page in the application and call a view model class that I define as @single on that page. I use a mutable object from the View model and update it, then I close the page. When I open the page back, it continues to use whatever the latest state of the viewmodel class is. I want it to recreate the viewmodel every time the page is opened. It's happening only ios not android. Here is my common DI file
    fun appModule() = listOf(AppModule().module)
    
    @Module
    @ComponentScan("com.makswin.bifrost")
    class AppModule
    
    class DependencyInjection : KoinComponent {
        val listTrainingsViewModel: ListTrainingsViewModel by inject()
        val getLastTrainingViewModel: GetLastTrainingViewModel by inject()
        val addFeedbackViewModel: AddFeedbackViewModel by inject()
        val insuranceViewModel: InsuranceViewModel by inject()
        val authViewModel: AuthViewModel by inject()
    }
    
    fun initKoin() {
        startKoin {
            modules(appModule())
        }
    }
    My App Delegate on ios
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        AppModuleKt.doInitKoin()
        return true
      }
    Here is my observable view model object
    class ObservableListTrainingViewModel : ObservableObject {
      @Published var state: ListTrainingsState?
       
      var viewModel: ListTrainingsViewModel?
       
      init(viewModel: ListTrainingsViewModel) {
        self.viewModel = viewModel
        asPublisher(viewModel.state)
          .compactMap { $0 }
          .receive(on: DispatchQueue.main)
          .assign(to: &state)
      }
    }
    Here is my sample swift ui view
    struct ContentView : View {
       
      @Environment(\.presentationMode) var presentationMode
       
      @ObservedObject var viewModel: ObservableListTrainingViewModel
    
      init() {
        viewModel = ObservableListTrainingViewModel(viewModel: DependencyInjection().listTrainingsViewModel)
      }
       
      var body: some View {
         
          VStack {
            if let state = viewModel.state {
              Button("Button") {
                if state.trainings.isEmpty {
                  self.viewModel.viewModel?.getTrainings(type: .next) // api call
                } else {
                  presentationMode.wrappedValue.dismiss() // close the page
                }
              }
              if state.isLoading {
                Text("LOADING")
              }
              if !state.trainings.isEmpty {
                Text("\(state.trainings.first?.title ?? "NONE")")
              }
            }
          }
      }
    }
    and my Common View Model Class
    @Single
    class ListTrainingsViewModel(val listTrainingsUseCase: ListTrainingsUseCase) : ViewModel() {
    
        private val _state: MutableStateFlow<ListTrainingsState> = MutableStateFlow(ListTrainingsState())
        val state: CommonFlow<ListTrainingsState> = _state.asCommonFlow()
    
        fun getTrainings(type: TrainingListTimeType) {
    
            listTrainingsUseCase(type).collectCommon { result ->
                when (result) {
                    is Resource.Error -> {
                        _state.value = ListTrainingsState(error = result.message ?: "")
                    }
                    is Resource.Loading -> {
                        _state.value = ListTrainingsState(isLoading = true)
                    }
                    is Resource.Success -> {
                        _state.value = ListTrainingsState(
                            trainings = result.data ?: emptyList(),
                            isLoading = false
                        )
                    }
                }
            }
    
        }
    
    }
    
    fun <T> Flow<T>.collectCommon(
        coroutineScope: CoroutineScope? = null,
        callback: (T) -> Unit,
    ): Job {
        return onEach {
            callback(it)
        }.launchIn(coroutineScope ?: CoroutineScope(Dispatchers.Main))
    }
    How can i solve this issue ?
    👀 1
    • 1
    • 1
  • v

    Vivek Modi

    07/19/2022, 10:55 AM
    Hey guys, I am using koin compose in my project. I see the example of sample-compose from koin repository. I am getting weird issue on
    viewModelOf
    package com.vivek.sportsresult.di
    
    import org.koin.androidx.viewmodel.dsl.viewModelOf
    import org.koin.dsl.module
    
    val appModule = module {
        viewModelOf(::MainActivityViewModel)
    }
    Can someone how can I fix this error.
    a
    m
    • 3
    • 15
  • a

    arnaud.giuliani

    07/21/2022, 9:40 AM
    taking few weeks off - summer break 🏖️ See you 👋
    🏖️ 8
  • c

    carloxavier

    07/21/2022, 10:51 AM
    hey guys! we are migrating our android project to a newer kotlin (1.6), so we needed to migrate also koin from 3.1.2 to 3.2.0, but it seems the latest koin-test-junit4 and koin-test-junit5 require compatibility with java 11? we have it currently set to java 8 (see the error below) The stacktrace of the crash:
    Variant 'apiElements' capability io.insert-koin:koin-test-junit4:3.2.0 declares an API of a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
                  - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Variant 'runtimeElements' capability io.insert-koin:koin-test-junit4:3.2.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
                  - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
    I didn't find any official info about this change of source compatibility, any hint about this would be greatly appreciated, thanks
Powered by Linen
Title
c

carloxavier

07/21/2022, 10:51 AM
hey guys! we are migrating our android project to a newer kotlin (1.6), so we needed to migrate also koin from 3.1.2 to 3.2.0, but it seems the latest koin-test-junit4 and koin-test-junit5 require compatibility with java 11? we have it currently set to java 8 (see the error below) The stacktrace of the crash:
Variant 'apiElements' capability io.insert-koin:koin-test-junit4:3.2.0 declares an API of a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
          - Variant 'runtimeElements' capability io.insert-koin:koin-test-junit4:3.2.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
I didn't find any official info about this change of source compatibility, any hint about this would be greatly appreciated, thanks
View count: 16