Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

android - After adding Kapt plugin - A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

First of all,

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.

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.

(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

Along with the following

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

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.

enter image description here

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

Additional note:

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

  2. I use Koin for DI

Hope someone will help me out!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Replacing

kapt "android.arch.persistence.room:compiler:$room_version"

by

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

might fix it as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...