google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.41k stars 2.01k forks source link

Android Gradle plugin doesn't work in KMP modules #4130

Closed ARTI1208 closed 9 months ago

ARTI1208 commented 10 months ago

I've used dagger for DI in Android inside kotlin multplatform modules. However, updating dagger from 2.46.1 to versions 2.47 and later ones produces compile time errors

Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?

I didn't find any information related to this in release notes or any other place. Did dagger plugin dropped support for kmp modules?

kuanyingchou commented 10 months ago

Hi, @ARTI1208 , I just tried out Hilt in a KMP project but couldn't reproduce. Do you use @AndroidEntryPoint? And if so can you confirm that Hilt Gradle Plugin is applied?

ARTI1208 commented 10 months ago

Yes, I use @AndroidEntryPoint and plugin is applied (if it wasn't then how it could work with 2.46.1?) I made a simple project ( similar to my actual one) with the error? please take a look https://github.com/ARTI1208/DaggerPluginFailRepro. You can return 2.46.1 in buildSrc/build.gradle.kts to test that it worked with that version

kuanyingchou commented 9 months ago

Hi, @ARTI1208 , thanks for the repro. This is indeed a regression in Hilt Gradle Plugin. We've submitted a fix and it will be included in the next Dagger release.