【发布时间】:2020-07-06 22:46:42
【问题描述】:
我在 DataBindingMapperImpl.java 中遇到一个特定数据绑定的错误,这会在构建项目时导致以下错误。
用于代码生成的 ANTLR 工具版本 4.5.3 与当前运行时版本 4.7.1 不匹配。
用于解析器编译的 ANTLR 运行时版本 4.5.3 与当前运行时版本 4.7.1 不匹配用于代码生成的 ANTLR 工具版本 4.5.3 与当前运行时版本 4.7.1 不匹配
用于解析器编译的 ANTLR 运行时版本 4.5.3 与当前运行时版本 4.7.1 不匹配
/Users/casper/Documents/ARCore/Name/app/build/generated/source/kapt/nameDebug/com/company/name/DataBinderMapperImpl.java:10:错误:找不到符号
import com.company.name.databinding.ActivitySplashScreenBindingImpl;
^
symbol: class ActivitySplashScreenBindingImpl
> Task :app:kaptNameDebugKotlin FAILED
> Task :app:mergeExtDexNameDebug
location: package com.company.name.databinding
FAILURE: Build failed with an exception.
接着是下面的错误信息...
我关注了类似的帖子here 导致了这个,这是上面错误消息的结尾。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptNameDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
我也试过
- 清理项目,然后重建项目
- 文件 -> 使缓存无效/重新启动
- 打开和关闭 Android Studio
连接到数据绑定的布局文件是这样的
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewmodel"
type="com.company.name.ui.splashScreen.viewModel.SplashScreenViewModel"/>
<variable
name="tryAgainBtnHandler"
type="com.company.name.ui.splashScreen.viewModel.interfaces.TryAgainBtnHandler"/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.splashScreen.view.SplashScreenActivity">
解决方案
错误是由错误引起的。我确实设置了可见性
android:visibility="@{viewmodel.errorContainerVisible ? View.VISIBLE : View.GONE}"
忘记导入
<data>
<import type="android.view.View"/>
【问题讨论】:
-
请将您的解决方案作为答案发布,以帮助人们解决此问题,因为这就是 SO 的工作方式。
标签: android android-studio kotlin data-binding antlr4