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

当前回答

这个答案对于那些在同一台机器(WINDOWS操作系统)上从一个帐户(用户)切换到另一个用户的人很有用。

我也遇到过类似的问题

failure occurred while executing org.jetbrains.kotlin.gradle.internal.kaptwithoutkotlinctask

但理由是拒绝批准下面的文件

C:\Android\.gradle\caches\modules-2\files-2.1\com.android.tools.build.jetifier\jetifier-core\1.0.0-beta09\c98ee0e5579aed97e17f605a89b101115a2f5a61\jetifier-core-1.0.0-beta09.jar

问题场景

我所做的是,复制C:\Android。Gradle \从我以前的机器到新机器。我在新机器上使用的用户帐户是X,我创建了一个新帐户,然后删除了帐户X。

由于X是所有者,新帐户在权限方面存在问题。

解决方案是更换所有权或删除C:\Android。gradle\让Android Studio(AS)下载相同。 出于同样的原因,我在承诺时也遇到了所有权问题。 为了避免任何进一步的问题,我删除了C:\Android(其中包括.gradle, . Android, C:\Android\Local\Android\Sdk文件夹)重新安装了Android Studio。

Git子模块更新失败,提示“致命:在存储库中检测到可疑的所有权”

其他回答

什么都没用,我试了所有的方法,最后发现一个小错误造成了一个大问题。

返回到每个新创建的数据库文件,逐行仔细检查每个文件的代码。

检查Database类,检查Dao是否声明,例如,

abstract val commentDatabaseDao: CommentDatabaseDao

声明为val而不是var,这是在我的情况下,最终为这个解决。

在我的情况下,我只是重命名/settings.gradle中的rootProject.name 我再次重复这个动作,它的工作..我不明白为什么会发生这种事,但我希望这能帮助到其他人,节省他们的时间

我花了几天时间才找到这个问题的解决方案,使用了androidx的高级版本。生命周期:lifecycle-compiler插件。

实现“androidx.lifecycle: lifecycle-runtime: 2.2.0-alpha03”

kapt androidx.lifecycle: lifecycle-compiler: 2.2.0-alpha03

kapt "android.arch.lifecycle:compiler:1.1.1"

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

<<<<<<< HEAD

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

我也遇到了同样的问题,所以我试图通过做来获得更多的信息

gradle - >应用程序- > - > Build - >组装任务

在这之后,我得到确切的错误说“错误,而注释处理”。 我检查了最近调整的DAO类,发现其中一个方法返回类型没有定义。

//Before
@Query("SELECT countryName FROM country_table WHERE countryCode= :code")
    fun getCountryNameForCode(code: String)

//After
@Query("SELECT countryName FROM country_table WHERE countryCode= :code")
    fun getCountryNameForCode(code: String): String