Skip to content

False positive parametersOf() call site check for activityViewModel() #121

Closed

Description

@acmpo6ou

Hello!

Thank you for making this amazing plugin! I'm very happy about the new 1.2 version which supports the old DSL, and allows to check for compiler safety without even migrating from old DSL.

I do have one issue though.

I have a view model which expects a parameter to be injected:

class MyViewModel(
    @InjectedParam val url: String,
) // ...

I have an activity, which instantiates the view model using Koin:

val viewModel by viewModel<MyViewModel> {
    parametersOf("koin-is-best-injection-framework.com")
}

The activity hosts a fragment, which injects the same instance of the view model using activityViewModel():

val viewModel by activityViewModel<MyViewModel>()

This fails however with the following error:

[Koin][KOIN-D006] com.example.myapp.MyViewModel requires 1 injected param(s) but activityViewModel<MyViewModel>() has no parametersOf() at the call site.
Expected @InjectParam slots: url: String
Pass them via parametersOf(...) inside the lambda.

However, the parameters are already passed in the activity. Is there a way to mark the activityViewModel<MyViewModel>() somehow, so that Koin skips the parametersOf() check for it?

Thank you.

Activity

  1. arnaudgiuliani commented on Nov 2, 2026

    @arnaudgiuliani
    Member

    Patch #136 is fixing it in 1.2.2. Please give a try with it when release 👍

  2. added this to the 1.2.2 milestone on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions