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

当前回答

看起来房间图书馆和苹果M1芯片有问题。

将您的room lib版本更新到2.4.0-alpha03或更高版本,并重新同步项目。

为我工作!

其他回答

当我将ROOM添加到我的应用程序(Kotlin)时,我也遇到了同样的问题。 我花了很长时间才发现问题所在,最后才发现我是在用下面的方法给我的应用程序添加ROOM。

    //room
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    kapt "android.arch.persistence.room:compiler:1.1.1"

所以我把上面两行换成了下面的,摆脱了痛苦。

    def room_version = "2.2.6"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

如果对你有帮助,点击向上键:D

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

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

如果您正在使用Kotlin与Hilt

确保您已经注释了模块类

@Module
@InstallIn(SingletonComponent::class)
class AppModule {
//...
}

在终端上单击——stacktrace查看错误的详细信息。你可以在这里找到它:

M1芯片解决方案

如果你有一台MacBook Pro,那么在房间编译器之前添加kapt "org. x里尔:sqlite-jdbc:3.34.0"就有可能解决你的问题。

  kapt "org.xerial:sqlite-jdbc:3.36.0" // Only for computer with M1 CPU
  implementation("androidx.room:room-ktx:$room_version")
  kapt "androidx.room:room-compiler:$room_version"

点击这里查看更多信息。