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

Android Studio Kotlin编译错误求助:CompilationErrorException异常

Kotlin项目编译异常排查求助

开发Kotlin项目时触发如下编译异常:

Caused by: org.jetbrains.kotlin.gradle.tasks.CompilationErrorException: Compilation error. See log for more details

相关布局代码片段

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blue_background"
tools:context=".FeedActivity">

问题截图

问题截图

排查建议

  • 查看完整编译日志:点击AS底部「Build」面板,展开「Build Output」,找到具体错误详情(当前异常仅为顶层提示,日志内会包含语法错误、资源缺失等具体原因)
  • 检查资源完整性:确认drawable目录下存在blue_background资源文件,若缺失需补充或替换为已存在的drawable
  • 补全布局标签:当前提供的布局代码未闭合</androidx.constraintlayout.widget.ConstraintLayout>标签,补全后重新编译
  • 清理缓存重建:执行File -> Invalidate Caches... -> Invalidate and Restart,重启后重新构建项目
  • 检查版本兼容性:确认Kotlin版本与Android Gradle Plugin(AGP)版本匹配,版本不兼容易触发编译异常

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 08:34:58