首页 > 解决方案 > 如何识别android数据绑定中的错误?[AGP 4.0 +]

问题描述

最近我注意到数据绑定的错误根本不是描述性的。有人知道如何找到真正的错误消息而不是“后续”错误消息吗?

例如,我收到这样的错误:

...\build\generated\source\kapt\debug\com\company\example\DataBinderMapperImpl.java:18: error: cannot find symbol
import com.company.example.databinding.FragmentApplicationDetailsBindingImpl;
                                      ^
  symbol:   class FragmentApplicationDetailsBindingImpl


* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
   > java.lang.reflect.InvocationTargetException (no error message)

我从中得到的唯一信息是错误分别FragmentApplicationDetailsBinding在布局文件中或fragment_application_details.xml布局文件中。

错误导致绑定文件无法生成,因此它显然丢失了。但没有信息在生成FragmentApplicationDetailsBinding. :(

标签: androidandroid-databinding

解决方案


如果项目不起作用,请尝试清理并重建项目转到文件->使缓存无效/重新启动。


推荐阅读