Skip to content

KMP version of Dagger? #3916

Open
Open

Description

@Zeyad-37

Dagger is the king of DI on Android. With the rise of KMP & KMM only service locator libs are available. It would be great if Dagger can become a multiplatform DI framework to avoid all these runtime crashes

Activity

  1. Chang-Eric commented on Jul 11, 2023

    @Chang-Eric
    Member

    In order to do KMP we would have to finish KSP work (#2349). KMP is also a very large project as we would have to rewrite all of our generated code to be in Kotlin. We also still have to consider users who only use Java, so it would probably mean having two modes, which is a lot of extra work. Basically this is all to say, this is a lot of work and probably won't happen for a while given we aren't done with KSP yet.

  2. shalva97 commented on Jul 17, 2023

    @shalva97
  3. natros commented on Jul 17, 2023

    @natros
  4. shalva97 commented on Jul 17, 2023

    @shalva97

    Okay, my bad. At first I though it would be a good joke, but now when I read it, it looks weird

  5. robercoding commented on Apr 24, 2024

    @robercoding

    Hey folks, so it's been almost a year since the discussion started and Hilt has already made its transition to ksp.
    Got me thinking, any chance we might see Hilt jumping on the KMP train in 2025-26? Any buzz or plans floating around?
    That'd be awesome!

  6. Shusek commented on Apr 29, 2024

    @Shusek

    Hey folks, so it's been almost a year since the discussion started and Hilt has already made its transition to ksp. Got me thinking, any chance we might see Hilt jumping on the KMP train in 2025-26? Any buzz or plans floating around? That'd be awesome!

    Not all issues related to KSP are closed:
    area: ksp

  7. ryanw-mobile commented on May 4, 2024

    @ryanw-mobile

    Dagger(/Hilt) on Android is popular, as we see people prefer it over other available options.
    When extending Android projects to KMP, Dagger(/Hilt) would still be my first preference if had a choice. I know many others share the same thoughts when they have to consider other options on KMP for DI.

    I understand the effort is significant, but I hope the team can at least agree there is a plan to support KMP, even if the timeline does not exist yet? Thank you.

  8. Chang-Eric commented on May 6, 2024

    @Chang-Eric
    Member

    Currently, there aren’t plans to work on a KMP version of Dagger or Hilt right now. Our team has discussed this but it isn’t in our current roadmap. KSP is also still in alpha since there are still a number of edge cases we’re working on, so it is a bit premature for us start on KMP. Also, while KSP was a large project, KMP support might somehow be even larger in that we’d have to support generating Kotlin as well as Java (there are still Java users out there who may not want Kotlin generated) and we already know of some tough compatibility issues we’d have to deal with there. This isn't ruling out KMP support, but also just want to set realistic expectations.

  9. juliocbcotta commented on May 23, 2024

    @juliocbcotta

    Hey @Chang-Eric , is ksp in alpha? From their versioning scheme it doesn't seem to be the case.
    Do you keep a list of issues that are considered blockers ?(if you could share those, I would like to follow them)

  10. Chang-Eric commented on May 23, 2024

    @Chang-Eric
    Member

    @juliocbcotta Sorry if that was confusing, I meant to say Dagger's support of KSP is still in alpha.

    Most of what we're trying to resolve as blockers before moving our support from alpha to stable is performance and getting internal projects on to Dagger KSP successfully. There's some performance stuff discussed in #4180, but also there are a number of issues we've run into internally while trying to switch projects at Google over to KSP from KAPT. Some of those issues are internal only and some of them have publicly filed issues, but I don't really want to list them out here since I don't really want to drive traffic to them. We already work pretty closely with the KSP team internally and they know about the issues we're hitting, so I don't want to add pressure from people since they already know it is a priority.

  11. tprochazka commented on Mar 30, 2025

    @tprochazka

    It basically means the end of Hilt/Dagger or Android because even in a corporate environment, where everything happens really slowly, Hilt is becoming deprecated because of the focus on future kmp compatibility. Which is quite sad since it has some benefits over other solutions.

  12. Chang-Eric commented on Apr 23, 2025

    @Chang-Eric
    Member

    Giving an update as some things have changed since my last update a year ago and we never really gave an update on our new plans.

    Over the past months we have been working to support KMP and so this is now actually on our roadmap. We have been migrating to XPoet to support Kotlin generation, but even with that nearing completion, there are still a number of hurdles to cross like issues with nullability, visibility, generic types, and dependencies like our dependency on javax and jakarta. There’s no clear date when this will be done, especially since we’re still working on supporting KSP2 which is in itself a blocker for KMP, but we thought we should update this since we are at least working on it.

    It basically means the end of Hilt/Dagger

    We’re still here =)

  13. imSathish commented on Sep 17, 2025

    @imSathish

    Any Update on KMP support

  14. GXBaum commented on Aug 3, 2026

    @GXBaum

    Hey, I was wondering if there are any updates on KMP support, or if I missed any?
    Is this still on the roadmap?

    Thanks in advance!

  15. bcorso commented on Aug 11, 2026

    @bcorso

    @GXBaum yes, this is still on the roadmap. The progress slowed/stopped due to multiple issues -- first, the switch from KSP1 to KSP2, and then the shift to focus on KSP performance issues. However, the performance work is wrapping up and we are now in a position to get back to this soon.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions