I am using Android Studio for my Android projects. I faced an issue when builds crash with strange stacktrace, like this:
Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'.
java.lang.RuntimeException: failure, see logs for details.
cannot generate view binders java.lang.NullPointerException
at android.databinding.tool.reflection.ModelMethod.isBoxingConversion(ModelMethod.java:155)
at android.databinding.tool.store.SetterStore.isBetterParameter(SetterStore.java:946)
at android.databinding.tool.store.SetterStore.getBestSetter(SetterStore.java:838)
and it was seemed that the databinding became broken as whole.
I made refactoring before and moved classes between packages.
In my case, I relied on Android Studio when renaming and moving classes between packages. But it didn't proceed correction for XMLs of layouts where were references on refactored classes in the type
attribute of variable
element in data
.
So my previous type's value pointed to non existing files and build crashed.
It's simple mistake but it may take more time to find the source. Hope this would help someone.