kaptGenerateStubsDebugKotlin FAILED e: Could not load module <Error module> - Android Studio Project

i got this error when i try build project. I do not have any errors in compilator.

Source code:

> Task :app:kaptGenerateStubsDebugKotlin FAILED
e: Could not load module <Error module>

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* 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.

I try to

  • Restart and Invalidate cache
  • Reopen project
  • Update all dependencies
  • Restart Android Studio
  • Restart Computer


  • I just had same error, for me, there was an unused class and it had some wrong imports .. for some reason the compiler was never showing this error .. only when I tried to commit files into temp branch then code analysis showed me the error .. I removed that class, rebuilt, and then this Error module message was gone, build was successful .. try to perform: Analyze Code in your project as well, you might find out what the problem is.

    I've also read on some other forums, some guy facing same issue, for him it was generated code missing imports .. so you might also try to go through generated code in your project and check for missing imports there.