google/dagger

[KSP2] Dagger and Hilt incompatibility with KSP2

SimonMarquis opened this issue · 4 comments

Original issue reported on KSP google/ksp#1841

KSP tasks are failing because of a Hilt error when building with Kotlin 2.0.0-RC1 and KSP2 enabled:

  • SimonMarquis/QrCode
    > Task :app:kspDebugKotlin
    e: [ksp*** [Hilt*** Class java.lang.Object is not annotated with @AssistedFactory.
    [Hilt*** Processing did not complete. See error above for details.
    e: [ksp*** [Hilt*** Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (com.google.dagger.hilt.android)
    See https://dagger.dev/hilt/gradle-setup.html
    [Hilt*** Processing did not complete. See error above for details.
    e: [ksp*** [Hilt*** Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (com.google.dagger.hilt.android)
    See https://dagger.dev/hilt/gradle-setup.html
    [Hilt*** Processing did not complete. See error above for details.
    e: [ksp*** [Hilt*** Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? (com.google.dagger.hilt.android)
    See https://dagger.dev/hilt/gradle-setup.html
    
  • android/nowinandroid
    > Task :ui-test-hilt-manifest:kspDemoDebugKotlin FAILED
    e: [ksp] [Hilt] Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (com.google.dagger.hilt.android)
    See https://dagger.dev/hilt/gradle-setup.html
    [Hilt] Processing did not complete. See error above for details.
    
    > Task :core:analytics:kspDemoDebugKotlin FAILED
    e: [ksp] java.lang.NullPointerException: null cannot be cast to non-null type androidx.room.compiler.processing.XType
    
    This stacktrace also contains an error referenced in this KSP issue:

Dagger / HIlt currently does not support KSP2 as we are still working through the various breaking changes in the APIs. Moreover, the underlying processing library used by Dagger and Hilt (called XProcessing) needs to also be migrated, tracking issue is https://issuetracker.google.com/314151707