Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KSP2] @Inject fields may not be final - androidInjector in dagger.android.DaggerApplication #4615

Closed
SimonMarquis opened this issue Feb 21, 2025 · 3 comments

Comments

@SimonMarquis
Copy link

  • Dagger: 2.55 (latest)
  • KSP: 2.1.10-1.0.30 (latest stable)
  • ksp.useKSP2=true in gradle.properties

Compiling an Android app with this configuration, and the following Application class (we still rely on the DaggerApplication for legacy dagger graph):

@HiltAndroidApp
class MyApp : DaggerApplication()

leads to the following error:

> Task :app:kspReleaseKotlin
e: [ksp] @Inject fields may not be final - androidInjector in dagger.android.DaggerApplication

@Inject volatile DispatchingAndroidInjector<Object> androidInjector;

@bcorso
Copy link

bcorso commented Feb 21, 2025

This issue seems like a bug in KSP2 or XProcessing library, as Dagger just looks for the final modifier to report this error.

  1. Which version of Kotlin are you using?
  2. Does this issue happen with ksp.useKSP2=false?
  3. Does this issue happen with previous versions of Kotlin/KSP (e.g. Kotlin 2.0.21 and KSP 2.0.21-1.0.28)?

Note that KSP2 is not officially supported with Dagger yet. We're currently in the process of trying to support KSP2; however, there are still many issues/discrepancies with KSP2 compared to KSP1 so we are working with KSP team to address those issues.

I also realize this isn't a great place for users because KSP1 is not really guaranteed to work with Kotlin 2.1.x, so getting KSP2 support enabled is currently one of our top priorities.

(see also the discussion here: #4505 (comment)).

@SimonMarquis
Copy link
Author

  1. Which version of Kotlin are you using?

Sorry for not mentioning it, but since we are using KSP 2.1.10-1.0.30, we are relying on Kotlin 2.1.10

  1. Does this issue happen with ksp.useKSP2=false?

No, only with ksp.useKSP2=true

  1. Does this issue happen with previous versions of Kotlin/KSP

No idea, I'll try next week some other versions and will report back to you. 🫡

Note that KSP2 is not officially supported with Dagger yet.

I'm well aware, that's why I explicitly mentioned KSP2. I reported it to avoid "re-discovering" this issue when the 1st KSP2-compatible release becomes stable. I'd rather not have to wait for a patch/release cycle 😜

@bcorso
Copy link

bcorso commented Feb 25, 2025

Looks like this is a known regression in KSP 1.0.30: google/ksp#2346

Looks like it is slated to be fixed in 1.0.31 or you can try to downgrade to 1.0.29.

I'll close this bug since there's nothing to do on our side.

@bcorso bcorso closed this as completed Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants