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

当前回答

我这里也有同样的问题。在我的例子中,原因是我在一个dagger模块中忘记了@Module注释。

要找到这样一个AS警报的真正问题,有必要深入:标题中的消息它只是最后一个,1个或多个错误的原因显示在左侧选择根元素,这显示了你确切的问题,检查我的打印屏幕如下:

其他回答

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

@Inject
private lateinit var appAnalytics: AppAnalytics

to

@Inject
lateinit var appAnalytics: AppAnalytics

在我的情况下,我使用房间和我的一个databasDao方法有一个未使用的参数,不幸的是android工作室没有正确地警告我

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

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

是的,我也得到了这个错误,这也是一个房间相关的问题。

我已经定义了我的TypeConverters,但从未使用:@TypeConverters(TypeConverter.class)注释我的Room数据库。

在我的例子中,当我从jcenter()移动到mavenCentral()时,我得到了这个错误,我的一个依赖只在jcenter()上可用,而不是mavenCentral()。 所以我向github上的所有者提交了同样的问题,并将等待删除jcenter(),直到它被移动。