Anvil 2x slower than Dagger
See original GitHub issueI recently added Anvil to a project, that had both Dagger and dagger-android (sigh), and I noticed 2x-3x clean/incremental build times .
I managed to repro it in a sample project. First commit of that PR uses Anvil, second commit uses Dagger to contribute a module to the AppComponent.
Running gradlew --scan buildDegug for clean and incremental builds, in both commits yields the following:
with Anvil (1st commit)
- clean build -> https://gradle.com/s/bh7cxidxzkkc4
- incremental build -> https://gradle.com/s/mmcg6ee3wed4y
with Dagger (second commit)
- clean build -> https://scans.gradle.com/s/5tz6skgnhtxxa
- incremental build -> https://gradle.com/s/a75gqnc3uamcu
For the incremental builds, it seems that app:compileDebugKotlin is not incremental when using Anvil, I was not able to figure out why.
Note: To trigger incremental builds I just added a timber line into the Dummy#dummy method
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
Extending Anvil for Fun and Profit - Slack Engineering
Extending Anvil to enable new Dagger dependency injection patterns in our codebase. ... It slows down our builds with kapt, has a steep...
Read more >Crafting; All You Need to Know - Ashley and Micah English
Anvil + Any Knife = Dagger Anvil + Large Iron Bar = Two-Handed Sword ... You will need a pair of "immune to...
Read more >Crafting | Divinity: Original Sin - OldGames.sk
Category Input #1 Input #2 Output Skill
armor Anvil Cloth Scraps Homemade Cloth Boots Crafting 1
armor Anvil Leather Scraps Homemade Leather Boots Crafting 2
armor...
Read more >Statblocks & Sheets | World Anvil
Shortbow + 20 arrows ('well... shit. It'll do until I can get a firearm. I guess.') Thieve's tools ('time to force entry') 2x...
Read more >ivar_recipes.pdf - Divinity - Original Sin
[C2]: Slow Current, Ice Shard, Summon Ice Elemental, Rain, Minor Heal, Slow, ... Use it to kill Shambling Oaks. Spear. = Branch. +....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I don’t have any other recommendations. Like I said we only enable the Dagger annotation processor and Kapt in the final app module. Everywhere else we rely on Anvil to generate Dagger factories. We don’t use any other annotation processors. Because of that we saw a significant improvement in performance.
@vRallev thanks a lot. I have fixed the access to the sample project now.
I have run with
:app:assembleDebug --infoand it seems the task:app:compileDebugKotlinis incrementalHowever, when using anvil it takes a lot more time.
With dagger
with anvil
Could you shed some light as to why this happens?