google / dagger

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

KMP - Dagger in androidMain #4141

Open lubo-pisk opened 8 months ago

lubo-pisk commented 8 months ago

I am using Dagger for Kotlin Multiplatform project in androidMain, but my class in androidMain inherits from parent located in commonMain. Dagger is not able to generate code.

This problem can be fixed: kotlin.sourceSets.androidMain.kotlin?.srcDirs +=
 file("${project.projectDir}/src/commonMain/kotlin")

But new Kotlin compiler K2 doesn't support expect and actual classes in same module. Previous code can break this condition.

Do you have any idea how to fix this problem?

kuanyingchou commented 8 months ago

Hi, @lubo-pisk , thanks for reporting. Somehow I'm not able to reproduce this. Is it possible for you to provide a reproducible example?