You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio项目构建失败:kaptGenerateStubsDebugKotlin任务报错

Android Studio构建报错:kaptGenerateStubsDebugKotlin失败

项目基于WyjazdyOSP的firebase分支构建时出现以下报错,但编译器面板未显示任何错误:

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

已尝试以下操作但问题未解决:

  • 重启并清除Android Studio缓存
  • 重新打开项目
  • 更新所有依赖
  • 重启Android Studio
  • 重启电脑

可行排查方向

  • 核对kapt注解处理器配置:确保Room、Dagger等需要注解处理器的依赖,都正确使用kapt而非implementation引入,且版本与kotlin插件版本匹配
  • 执行深度清理构建:在终端运行./gradlew clean build --no-build-cache(Windows系统用gradlew.bat clean build --no-build-cache),彻底清理缓存后重新构建
  • 查看详细错误栈:执行./gradlew :app:kaptGenerateStubsDebugKotlin --stacktrace,通过完整错误信息定位具体出错的模块或注解
  • 检查注解语法:排查项目中使用注解的代码(如数据库实体类、依赖注入注解),确认没有语法错误或引用不存在的注解类
  • 检查模块依赖:查看项目中是否存在重复依赖、版本冲突,尤其是kotlin-stdlib、注解处理器相关依赖

内容的提问来源于stack exchange,提问作者GlobooX

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 04:21:59