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

当前回答

当我试图在一个活动中使用刀柄注入一个私有字段时,发生了这种情况。解决方案是删除private关键字,以便更改

@Inject
private lateinit var appAnalytics: AppAnalytics

to

@Inject
lateinit var appAnalytics: AppAnalytics

其他回答

如果你已经升级到类路径'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`

解决了只需增加gradle版本到最新

它在项目级别的gradle文件中,在dependencies块下。

classpath "com.android.tools.build:gradle:4.x.x"

在我的例子中,我添加了这一行

 android {
    .
    .
    .

    kapt.includeCompileClasspath = false

 }

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

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

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

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