This happens for both Dagger generated files and for LiveData generated binding files.
I'll change branches and the generated file for the new Live Data layout or the generated MemberInjector for a new daggeer component will stick around even though those new components are actually on the other branch.
I'll do a Invalidate caches and restart as well as a clean build. But it doesn't work. I even tried manually deleting the files and they just got regenerated.
The only way I've found to fix it is to uninstall android studio and reinstall it.
My co-worker who uses a mac does not experience this problem.
This might happen when using Gradle with the build cache enabled where it fails to recognize files no longer present after switching branches, so that it keeps recreating files that reference non-existant code.
Clearing the build cache directory (USER_HOME/.gradle/caches/build-cache-1
) helps resolve the issue
For myself, it was a combination of @David Medenjak's answer and a couple of other things.
rm -rf ~/.gradle/caches/build-cache-1/
build/generated
folder.Build > Rebuild Project
I fixed this kind of problem (dagger created fabric for deleted class) by:
gradle.properties
: org.gradle.caching=false
Building project
Restoring gradle.properties
:
org.gradle.caching=true
I also noticed that cleaning the project and deleting caches only doesn't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With