问题
I have a lot of issues with DataBinding when switching between Git branches where a databinding layout has been changed/removed. I regularly get build errors like this when a file is removed when switching Git branch:
<path>/build/generated/data_binding_base_class_source_out/debug/dataBindingGenBaseClassesDebug/out/com/some/package/databinding/SomeLayoutBinding.java:38: error: cannot find symbol
public final SomeOtherLayoutBinding variable;
...and try every combination of
- Clean Project
- ./gradlew cleanBuildCache
- Sync project with gradle
- Invalidate/Restart
but ultimately none of it resolves the issue.
The only thing I've found that works is to clear the gradle cache in my home directory like:
rm -rf ~/.gradle/caches
however this results in my next build taking up to 10min.
Is it really supposed to be like this? Why can't it detect that a file is added/removed when switching branch?
来源:https://stackoverflow.com/questions/58340113/handling-databinding-errors-when-switching-git-branch