question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Hilt] Incremental kapt does not always regenerate references to other modules

See original GitHub issue

This 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 a TextView which toString’s the injected dependencies. See MainActivity.kt.
  • :library: A library which provides multiple implementations of CoffeeMaker using multi- bindings. See Coffee.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:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
danysantiagocommented, Sep 25, 2020

Done, created an issue with a more minimal sample project: https://youtrack.jetbrains.com/issue/KT-42182

2reactions
danysantiagocommented, Sep 22, 2020

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. 🧐

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gradle Build Setup - Dagger
To use Hilt, add the following build dependencies to the Android Gradle module's ... If using Kotlin, then apply the kapt plugin and...
Read more >
How to get rid of Incremental annotation processing requested ...
From version 1.3.30+, incremental processing allowed modules not to be entirely processed again each time a change occurs, giving the build ...
Read more >
Incremental annotation processor recompile all files (only if ...
The issue here is that KAPT expects originating elements to be from the sources it is currently processing. Running with master , where...
Read more >
Making incremental KAPT work (Speed Up your Kotlin projects!)
apt=true in your project's gradle.properties; Make sure that all annotation processors in the module support incremental kapt . The whole Gradle ...
Read more >
Migrating Room databases | Android Developers
Export schemas; Test a single migration; Test all migrations ... Room supports both automated and manual options for incremental migration.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found