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

当前回答

我花了几天时间才找到这个问题的解决方案,使用了androidx的高级版本。生命周期:lifecycle-compiler插件。

实现“androidx.lifecycle: lifecycle-runtime: 2.2.0-alpha03”

kapt androidx.lifecycle: lifecycle-compiler: 2.2.0-alpha03

kapt "android.arch.lifecycle:compiler:1.1.1"

其他回答

在我的情况下,有旧的依赖需要升级, 所以你可以这样做:

1.文件->项目结构->

2.进入建议->

3.在警告部分,Android工作室会告诉你哪些依赖 需要升级->

4.只需从那里直接升级它->

5.单击APPLY - - - >

现在就可以了!

谢谢!

也许我回答的有点晚了,但是不管怎样,我得到了同样的错误。构建失败可能是由Android Studio未能指出的一些错误引起的,可能是由于项目规模非常大。

下面是指出确切错误的简单方法。

在Android studio的分析菜单,点击检查代码;检查整个项目,单击“确定”,等待检查完成。 现在你会看到一个标签,将指出所有的错误,警告等,你现在可以解决真正的问题。

如果你已经升级到类路径'com.android.tools.build:gradle:4.0.0' 替换之前的版本

dependencies {
    classpath 'com.android.tools.build:gradle:3.6.3'
}

和Change gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-   all.zip`

找出潜在问题的方法是运行以下命令:

./gradlew assembleDebug --stacktrace

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

我意识到……

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

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

你猜怎么着?

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

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

祝你过得愉快。