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

[KSP] After migrating to ksp Assisted Inject factory implementations cannot be found during incremental compilation #4054

Closed
AradiPatrik opened this issue Sep 1, 2023 · 5 comments

Comments

@AradiPatrik
Copy link

As title says. I am using assisted inject, and after upgrading to KSP my incremental compilation is broken and have to do clean builds every time. I get the error below

android gradle: "com.android.tools.build:gradle:8.1.1"
gradle plugin: "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
ksp version: 1.9.0-1.0.13
dagger version: 2.48

gradle info

------------------------------------------------------------
Gradle 8.3-rc-2
------------------------------------------------------------

Build time:   2023-07-26 15:20:39 UTC
Revision:     c48101dc7f9c766efa8206574aa9c2195d2b7960

Kotlin:       1.9.0
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.8 (JetBrains s.r.o. 17.0.8+7-b1000.8)
OS:           Mac OS X 13.0 aarch64

cannot find symbol
import my.package.impl.faceselector.screen.model.FaceSelectorScreenViewModel_Factory_Impl;
                                                ^
  symbol:   class FaceSelectorScreenViewModel_Factory_Impl
  location: package my.package.impl.faceselector.screen.model
@bcorso
Copy link

bcorso commented Sep 1, 2023

Hi @AradiPatrik, can you share a minimal reproducible example? AFAIK, we've done everything on Dagger's side to make this work, so it may be a bug in KSP.

@tevjef
Copy link

tevjef commented Sep 12, 2023

@bcorso A reproducer of this bug is in this repo/branch and here is a github action run with the failure.

/home/runner/work/android-bugs/android-bugs/app/build/generated/ksp/debug/java/com/company/myapplication/DaggerComponent.java:65: error: cannot find symbol

> Task :app:compileDebugJavaWithJavac FAILED
      this.factoryProvider = BugDemonstration_Factory_Impl.create(bugDemonstrationProvider);
                             ^
  symbol:   variable BugDemonstration_Factory_Impl
  location: class ComponentImpl
1 error

Workaround: Making the @AssistedFactory interface a top-level class seems to work.

I have been running into other incremental compilation issues that I haven't been able to reproduce and will revert to kapt until dagger ksp is in a more stable space.

@AradiPatrik
Copy link
Author

@tevjef Thanks for the repro! For me this issue is sometimes still present after clean build. The only way to work around the issue is actually delete a line in the generated file (referencing the factory), and rebuild the project.

@bcorso
Copy link

bcorso commented Sep 13, 2023

@tevjef thanks for the repro. We're currently working with KSP team to figure out if this is an issue in Dagger, KSP, or Gradle. There's a few similar issues (#4063, #4060) and we have a couple repros now. I'll update again once we figure out what the fix needs to be.

@bcorso
Copy link

bcorso commented Sep 28, 2023

A quick update on this -- this appears to be an issue with how KSP exposes its output cache during incremental processing. I've filed a bug with the KSP team here: google/ksp#1555.

In the meantime, it is possible to workaround this issue in Dagger until the issue gets resolved in KSP. We should have the fix out this week and hopefully do a release as well.

copybara-service bot pushed a commit that referenced this issue Sep 29, 2023
This change should be temporary until we can get a more robust fix in KSP (google/ksp#1555).

Fixes #4063
Fixes #4054

RELNOTES=N/A
PiperOrigin-RevId: 568629041
copybara-service bot pushed a commit that referenced this issue Sep 29, 2023
This change should be temporary until we can get a more robust fix in KSP (google/ksp#1555).

Fixes #4063
Fixes #4054

RELNOTES=N/A
PiperOrigin-RevId: 568629041
copybara-service bot pushed a commit that referenced this issue Sep 29, 2023
This change should be temporary until we can get a more robust fix in KSP (google/ksp#1555).

Fixes #4063
Fixes #4054

RELNOTES=N/A
PiperOrigin-RevId: 568629041
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

Successfully merging a pull request may close this issue.

3 participants