突然我开始得到这个错误,我不知道为什么如果有人告诉我这个错误在哪里,就足够有帮助了。正如我所能得到的,这是因为android studio的新更新。 我得到的错误的详细总结。

Task :app:kaptDebugKotlin
    ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1C:\Users\shubh\Downloads\MarginCalculator\app\build\generated\source\kapt\debug\com\kotlin_developer\margincalculator\DataBinderMapperImpl.java:10: error: cannot find symbol
    import com.kotlin_developer.margincalculator.databinding.FragmentCalculatorScreenBindingImpl;

    symbol:   class FragmentCalculatorScreenBindingImpl

    Task :app:kaptDebugKotlin FAILED
    location: package com.kotlin_developer.margincalculator.databinding
    FAILURE: Build failed with an exception.

* 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)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 17s
29 actionable tasks: 27 executed, 2 up-to-date

当前回答

如果有人面临这个错误,由于添加测试依赖柄(这是我面临这个错误的原因) 确保正常依赖项和测试依赖项的版本相同

// Hilt Dependency 实现“com.google.dagger: hilt-android: 2.38.1” kapt com.google.dagger: hilt-compiler: 2.38.1

//测试柄 androidTestImplementation com.google.dagger: hilt-android-testing: 2.38.1 kaptAndroidTest com.google.dagger: hilt-android-compiler: 2.38.1

其他回答

我也遇到了同样的问题,所以为了尝试,我删除了项目的。idea文件夹和。gradle文件夹,然后我也删除了app文件夹内的build文件夹,然后重新启动android studio IDE,它为我工作

在我的情况下,我解决它更新我的kotlin版本从1.3。X到1.6.0。

改变

implementation "android.arch.persistence.room:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"

来 (更新4 -2021年9月)

 implementation "androidx.room:room-runtime:2.3.0"
 annotationProcessor "androidx.room:room-compiler:2.3.0"

在我的情况下,我忘记在实体类中添加@PrimaryKey。

检查柯特林和刀柄的兼容版本