突然我开始得到这个错误,我不知道为什么如果有人告诉我这个错误在哪里,就足够有帮助了。正如我所能得到的,这是因为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

当前回答

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

其他回答

我也有同样的问题。在我的情况下,问题是关于数据库。我必须修改这行代码 @数据库(实体= [SearchedLocation::class, FavoriteLocation::class],版本= 1)

我在数据库中添加了另一个表,但忘记在上面的行中添加表。

我刚刚将Android Studio IDE更新到4.1.1版本,并得到了类似的问题。

我意识到……

在我没有一些*_Impl类之前(我知道它们在Kotlin的东西中),甚至没有一些新的*Tests类。

所以,在“运行所有的世界”之后,我做出了一个直观而公平的选择:我删除了我的“手工构建”包中的所有文件,这些文件在Android Studio更新之前并不存在。

你猜怎么着?

它工作。没有问题,关于kapt一点问题都没有。

我并不是说这是最终的解决方案。但它可以为你工作。

祝你过得愉快。

如果您正在使用Kotlin与Hilt

确保您已经注释了模块类

@Module
@InstallIn(SingletonComponent::class)
class AppModule {
//...
}

这事就发生在我身上。另一个开发人员没有正确地完成合并,所以这一行在代码中

<<<<<<< HEAD

而不是得到一个编译错误,我得到了KaptExecution错误。

在经历了许多痛苦之后,我决定尝试annotationProcessor而不是kapt,希望它至少可以显示错误消息或任何可以帮助我定位源代码的东西。但幸运的是(或不幸的是;由于浪费了时间),它成功地建立了,没有任何错误。 这主要是kapt本身的一个bug。所以,试试这个方法,它可能会有帮助。