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

当前回答

在我的情况下,我解决它更新我的kotlin版本从1.3。X到1.6.0。

其他回答

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

我有一个枚举在我的实体属性使用房间。经过长时间的搜索,导致如下失败。

“:app:kaptDebugKotlin”任务执行失败。 执行org.jetbrains.kotlin.gradle.internal.KaptExecution时发生失败 invocationtargetexception(没有错误消息)

enum class Color{RED,BLACK,BLUE,GREEN,WHITE}
@Entity(tableName = "flower_table")
data class Flower(
        @PrimaryKey(autoGenerate = true) val id: Int,
        @ColumnInfo(name = "name") val name: String,
        @ColumnInfo(name = "color") val color: Color)

val flower = Flower(2, "rose", Color.RED)

我的解决方案是在实体属性中使用枚举的索引。

@Entity(tableName = "flower_table")
data class Flower(
        @PrimaryKey(autoGenerate = true) val id: Int,
        @ColumnInfo(name = "name") val name: String,
        @ColumnInfo(name = "color") val color: Int)

val flower = Flower(4, "tulip", Color.BLUE.ordinal)

希望能对你有所帮助! PS,不要忘记更新数据库类中的版本号。

@Database(entities = [Flower::class], version = 2)
abstract class FlowerRoomDatabase : RoomDatabase() {

对我来说,这个问题的发生是因为java版本的差异 对我来说 -我的工作室默认java版本是11 -我有一个库在我的项目与java版本8支持

修复, 1.使用命令/usr/libexec/java_home -V列出所有已安装的java版本 2.拷贝java8路径:/Library/Java/JavaVirtualMachines/1.8.0_232.jdk/Contents/Home 3.去 文件-项目结构- SDK位置- jdk位置 在那里添加你的java路径

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

<<<<<<< HEAD

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

如果你安装了新的kotlin插件(1.4.20-release-Studio4.1-1)并安装了dagger (kapt 'com.google.dagger:dagger-compiler:2.30'),也会出现这个问题。在这种情况下,一种解决方案可能是用视图绑定替换已弃用的插件:'kotlin-android-extensions' (https://developer.android.com/topic/libraries/view-binding)