Android数据绑定'错误:无法生成视图绑定器java.lang.NullPointerException'

时间:2017-02-02 07:20:01

标签: java android exception android-databinding

由于数据绑定,我在制作项目时遇到错误。 我无法理解他们的日志和异常堆栈跟踪。

整个成绩控制台错误说

失败:构建因异常而失败。

  • 出了什么问题: 任务':app:compileFlavorSuperwiseDebugJavaWithJavac'的执行失败。
      

    java.lang.RuntimeException:失败,请参阅日志了解详细信息。   无法生成视图绑定器java.lang.NullPointerException   在android.databinding.tool.reflection.ModelMethod.isBoxingConversion(ModelMethod.java:155)   在android.databinding.tool.store.SetterStore.isBetterParameter(SetterStore.java:946)   在android.databinding.tool.store.SetterStore.getBestSetter(SetterStore.java:838)

.. ... .....

at android.databinding.tool.store.SetterStore.getSetterCall(SetterStore.java:672)
at android.databinding.tool.Binding.getListenerParameter(Binding.java:164)
at android.databinding.tool.CompilerChef.sealModels(CompilerChef.java:200)
at android.databinding.annotationprocessor.ProcessExpressions.writeResourceBundle(ProcessExpressions.java:149)
at android.databinding.annotationprocessor.ProcessExpressions.onHandleStep(ProcessExpressions.java:82)
at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.runStep(ProcessDataBinding.java:154)
at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.access$000(ProcessDataBinding.java:139)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:66)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
android.databinding.annotationprocessor.ProcessExpressions.onHandleStep(ProcessExpressions.java:85)
at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.runStep(ProcessDataBinding.java:154)
at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.access$000(ProcessDataBinding.java:139)
at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:66)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
... 90 more

消息日志说明了这个

Error:cannot generate view binders java.lang.NullPointerException
Error:java.lang.RuntimeException: java.lang.RuntimeException:
failure, see logs for details.
Error:java.lang.RuntimeException: failure, see logs for details.

从我读到的内容我已经确定了三元运算符中的原始数据类型转换。 我仍然不知道哪个模型/绑定导致它。

代码中包含许多Spinner,与InverBinding Adapter和BindingAdaptor绑定的Edittext。我知道没有代码很难指出错误。但我的整个项目都有数据绑定。我不知道要发布哪一个。您是否可以了解我如何知道编译失败的位置?

谢谢

1 个答案:

答案 0 :(得分:-2)

我刚刚找到了如何通过切换gradle版本来获取错误详细信息。 我只是改变了

的成绩版本
classpath 'com.android.tools.build:gradle:2.2.0'   

classpath 'com.android.tools.build:gradle:2.0.0'

这篇文章也帮助了我InversDataBinding Support

希望这有助于某人。