“错误:无法生成视图绑定程序java.lang.NullPointerException"的可能原因 [英] Possible reason for "Error:cannot generate view binders java.lang.NullPointerException"

查看:353
本文介绍了“错误:无法生成视图绑定程序java.lang.NullPointerException"的可能原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Android Studio用于我的Android项目.当构建因奇怪的stacktrace而崩溃时,我遇到了一个问题,像这样:

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.

推荐答案

就我而言,在包之间重命名和移动类时,我依赖Android Studio.但是,对于在datavariable元素的type属性中对重构类进行引用的布局的XML,它并没有进行更正.

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.

这篇关于“错误:无法生成视图绑定程序java.lang.NullPointerException"的可能原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆