添加Kapt插件后-执行org.jetbrains.kotlin.gradle.internal.KaptExecution时发生故障 [英] After adding Kapt plugin - A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

查看:6185
本文介绍了添加Kapt插件后-执行org.jetbrains.kotlin.gradle.internal.KaptExecution时发生故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先

我非常清楚,关于此错误的很多问题已经在此处发布,而且似乎都没有一个适当的解决方案,尤其是我需要的解决方案.

I'm pretty much aware that a lot of questions on this error had been posted already here, and none of them seems to be having a proper solution especially the one I need.

我坚持了一个星期以上的以下错误.

I'm stuck with the following error for over a week.

我正在研究一个使用Kotlin,MVVM,Clean Arch和Navigation Components构建的android项目.

I'm working on an android project which is being built using Kotlin, MVVM, Clean Arch, and Navigation Components.

我最近添加了领域数据库,为此我不得不添加以下插件.

I recently added realm database, and for that I had to add the following plugins.

apply plugin: 'kotlin-kapt'

apply plugin: 'realm-android'

真正的问题是从这里开始的.

The real problem started from here I think.

(此后,我添加了一个DatabaseManager类,该类利用我编写的用于数据库操作的某些领域扩展功能.)

(After that I added a DatabaseManager class which makes use of some realm extension functions I wrote to make db operations.)

此后我编译项目时,总体上发生以下错误.

When I compile the project after this, the following error occurred overall.

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

以及以下内容

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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 7s
30 actionable tasks: 6 executed, 24 up-to-date

它指向我的MainActivity类,该类保持不变,并且似乎对此没有任何错误或错别字. 我非常确定kapt注释处理器在此处似乎无法弄清它们的作用.

It points to my MainActivity class which is unaltered and doesn't seem to have any errors or typos for that matter. I'm pretty much sure that the kapt annotation processor does some dirty job here that I do not seem to figure out.

如果我能够克服这个奇怪的错误,我将感到极大的放心.

I will be greatly relieved if I could get past this weird error.

附加说明:

  1. 我已经将整个项目分为三个模块.这三个人都有kapt插件(以防万一)

  1. I have separated my entire project into three modules. All three got kapt plugin (just incase)

我将Koin用于DI

I use Koin for DI

希望有人会帮助我!

推荐答案

经过一周的努力,我终于找到了问题.

After a week's struggle, I finally found the issue.

我为领域添加了kotlin-kapt插件.

我自己有一个名为interface的文件夹,用于保存某些接口.

And I had a folder named interface itself to hold some interfaces.

我从MainActivity的interface文件夹中实现了一个接口.

I implemented one of the interfaces from the interface folder in MainActivity.

现在界面的import就是这样,

import com.android.app.java.interface.Listener

在这里,关键字interface混淆了注释处理器,因此在生成存根时导致错误.

Where, the keyword interface confused the annotation processor, hence caused error while generating stub.

我已将文件夹重命名(从interface更改为intrface).

I renamed the folder (from interface to intrface).

这解决了错误.

这是一个非常简单的错误,花费了我一周的时间.

This is a very simple mistake that cost me a week.

无论如何,找到了问题.是的!

Anyway, found the issue. Yay!

这篇关于添加Kapt插件后-执行org.jetbrains.kotlin.gradle.internal.KaptExecution时发生故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆