[Hilt] Incremental kapt does not always regenerate references to other modules
See original GitHub issueThis may be a duplicate of #1684 but I wanted to provide a reproducible example just in case, since that issue seems to have gone stale (and was not reproducible at the time). The sample can be found here: https://github.com/damianw/HiltIncrementality
The sample consists of two Gradle modules:
:app
: The application, which is just a single activity with aTextView
whichtoString
’s the injected dependencies. SeeMainActivity.kt
.:library
: A library which provides multiple implementations ofCoffeeMaker
using multi- bindings. SeeCoffee.kt
.
Issue
The issue has something to do with failing to regenerate code after making changes in library
. To
start, build the app from clean:
./gradlew :app:assembleDebug
This should build successfully. Then, uncomment the val water: Water
lines from Coffee.kt
, and
build :app:assembleDebug
again. The expected behavior is that this builds successfully. Instead,
the build will fail with:
/Users/damian/Development/HiltIncrementality/app/build/generated/source/kapt/debug/com/example/hiltincrementality/DaggerApp_HiltComponents_SingletonC.java:61: error: constructor DripCoffeeMaker in class DripCoffeeMaker cannot be applied to given types;
local = new DripCoffeeMaker();
^
required: Water
found: no arguments
reason: actual and formal argument lists differ in length
/Users/damian/Development/HiltIncrementality/app/build/generated/source/kapt/debug/com/example/hiltincrementality/DaggerApp_HiltComponents_SingletonC.java:75: error: constructor PourOverCoffeeMaker in class PourOverCoffeeMaker cannot be applied to given types;
local = new PourOverCoffeeMaker();
^
required: Water
found: no arguments
reason: actual and formal argument lists differ in length
/Users/damian/Development/HiltIncrementality/app/build/generated/source/kapt/debug/com/example/hiltincrementality/DaggerApp_HiltComponents_SingletonC.java:89: error: constructor EspressoCoffeeMaker in class EspressoCoffeeMaker cannot be applied to given types;
local = new EspressoCoffeeMaker();
^
required: Water
found: no arguments
reason: actual and formal argument lists differ in length
Cleaning (either which Gradle or rm -rf app/build
) will fix the problem (allowing the app to build
again) at the loss of incrementality. The same problem now exists in reverse, if you were to re-
comment the val water: Water
line .
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:12 (6 by maintainers)
Top GitHub Comments
Done, created an issue with a more minimal sample project: https://youtrack.jetbrains.com/issue/KT-42182
An update: I’ve created the same project in Java (HiltIncrementalityJava.zip) and was not able to reproduce the issue, which is making
kapt
very suspicious as the possible culprit of this issue. 🧐