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

当前回答

在某些情况下,这可能会有所帮助 gradle.properties

kapt.include.compile.classpath=true

其他回答

我有同样的错误一段时间,然后我开始检查其他包,我知道我在我的数据库代码中犯了一个打字错误。所以, “检查你的数据库和其他活动类文件,你可能会发现一些错误。”

在我的情况下,我使用协程,但我忘记添加Kotlin扩展和协程支持的房间

Def room_version = "2.2.6" 实现“androidx.room: room-ktx: room_version美元”

以我为例:问题解决了

步骤:

删除viewModel变量-在XML中。

<variable
    name="viewModel"
    type="com.xx.AppViewModel" / >

删除了所有viewModel绑定引用-在XML中。

android:text="@{viewModel.simName}"

删除了对绑定映射- In活动的viewModel实例引用

binding.viewModel = viewModel

清理项目并重新编译。 在XML & Build项目中添加viewModel变量。

< variable
    name="viewModel"
    type="com.xx.AppViewModel" / >

将viewModel实例引用添加到绑定映射-在活动和构建项目中

binding.viewModel = viewModel

添加所有viewModel绑定引用-在XML & Build项目中..

    android:text="@{viewModel.simName}"

它现在可以工作了。

——我希望这对你也有用。

在我的情况下,添加新的片段总是会导致这个错误弹出,我调查了我在git上的提交更改,结果发现,每当我创建一个新的片段时,Android都会自动更新gradle插件,尽管没有给予它这样做的权限,所以我不得不回滚到我最初的gradle插件版本的项目级别的构建。gradle文件:

from

类路径的org.jetbrains.kotlin: kotlin-gradle-plugin: 1.7.0

to

classpath“org . jetbrains kotlin kotlin-gradle-plugin: 1。6 . 21”

监控你的git变化,找出Android对你的gradle文件做了什么,导致它崩溃。

我也犯了同样的错误。 我有两个问题。

您可能需要添加 实现“2.2.5 androidx.room: room-ktx)” 我删除了一个在activity_xml文件中作为成员引用的文件。这个错误从来没有给我任何线索,直到我把它改为annotationProcessor而不是kapt,然后它指出了错误,我找到了这个文件,果然我有一个引用到一个我不再使用并被删除的文件。我从xml中删除了这个数据引用,并将其全部清除。然后我把它放回去。