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

当前回答

我得到了同样的错误,对我来说,问题是我需要从Gradle JDK版本16.0.1切换到Android Studio java家庭版本11.0.10在Android Studio >首选项…>构建,执行,部署>构建工具> Gradle

其他回答

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

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

我得到了同样的错误,对我来说,问题是我需要从Gradle JDK版本16.0.1切换到Android Studio java家庭版本11.0.10在Android Studio >首选项…>构建,执行,部署>构建工具> Gradle

我也遇到了同样的问题,所以我试图通过做来获得更多的信息

gradle - >应用程序- > - > Build - >组装任务

在这之后,我得到确切的错误说“错误,而注释处理”。 我检查了最近调整的DAO类,发现其中一个方法返回类型没有定义。

//Before
@Query("SELECT countryName FROM country_table WHERE countryCode= :code")
    fun getCountryNameForCode(code: String)

//After
@Query("SELECT countryName FROM country_table WHERE countryCode= :code")
    fun getCountryNameForCode(code: String): String

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

Android Studio的UI只是隐藏了错误……

当错误发生时,它会突出显示列表视图中的项目,并在终端视图中显示一条无用的消息。

要找到真正的错误,在列表视图中选择根项,这样Android Studio就会在终端视图中显示整个构建输出,然后滚动以找到错误。