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][Android] Delete a hilt view model breaks incremental compilation in ksp #4060

Closed
ZhaohuaZeng-at opened this issue Sep 7, 2023 · 2 comments

Comments

@ZhaohuaZeng-at
Copy link

ZhaohuaZeng-at commented Sep 7, 2023

Hi team,

Congrats on the KSP release!
After migrating to KSP, I found that there is an issue related to @HiltViewModel in my Android project. If I delete the view model, the incremental compilation will break in KSP, with the following message:

/Users/zhaohua.zeng/AndroidStudioProjects/testhiltviewmodel/app/build/generated/ksp/debug/java/com/example/testhiltviewmodel/ProfileScreenViewModel_HiltModules_KeyModule_ProvideFactory.java:34: error: package ProfileScreenViewModel_HiltModules does not exist
    return Preconditions.checkNotNullFromProvides(ProfileScreenViewModel_HiltModules.KeyModule.provide());

I also created a simple repository to demonstrate this issue: https://github.com/ZhaohuaZeng-at/dagger-demo-viewmodel-bug-ksp
Overview of the repo branches:

  • main: use KSP for dagger and hilt. Has one hilt view model ProfileScreenViewModel
  • remove_viewmodel: In this branch, I remove the ProfileScreenViewModel
  • kapt: Use Kapt instead for dagger and hilt.
  • kapt-remove-viewmodel: Same as the remove_viewmodel branch but use kapt

Here is the steps to reproduce:

  1. build project in main branch via "run app"
  2. git checkout remove_viewmodel, build project incrementally via "run app"
  3. see the compilation fails.

If I do a clean build in remove_viewmodel, build can succeed, but this is annoying.
This error is not reproducible with the kapt and kapt-remove-viewmodel branches.

@ansman
Copy link

ansman commented Sep 20, 2023

I saw this too when I deleted an @AutoBind annotated object (this annotation is provided by auto-dagger)

@bcorso
Copy link

bcorso commented Sep 25, 2023

This looks like an issue in KSP. I've filed a bug here: google/ksp#1554.

copybara-service bot pushed a commit that referenced this issue Nov 29, 2023
…0-1.0.14`.

This should bring in a number of fixes in KSP, especially related to incremental processing.

Fixes #4060

RELNOTES=Upgrade Dagger's dependencies of kotlin to `1.9.20` and ksp to `1.9.20-1.0.14`.
PiperOrigin-RevId: 586380958
copybara-service bot pushed a commit that referenced this issue Nov 29, 2023
…0-1.0.14`.

This should bring in a number of fixes in KSP, especially related to incremental processing.

Fixes #4060

RELNOTES=Upgrade Dagger's dependencies of kotlin to `1.9.20` and ksp to `1.9.20-1.0.14`.
PiperOrigin-RevId: 586380958
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