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

查看:67
本文介绍了添加 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 和导航组件构建的 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 插件.

I added the kotlin-kapt plugin for realm.

我有一个名为 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天全站免登陆