flutter安卓开发遇到的问题—— 2

Anrola Lv2

在build apk的时候出现满屏红字。
Caused by: java.lang.AssertionError: java.lang.Exception: Could not close incremental caches in…..
Caused by: java.lang.Exception: Could not close incremental caches in……
Suppressed: java.lang.IllegalArgumentException: this and base files have different roots:…..
Suppressed: java.lang.IllegalArgumentException: this and base files have different roots:….
Suppressed: java.lang.Exception: Could not close incremental caches in……
Suppressed: java.lang.IllegalArgumentException: this and base files have different roots:……
Caused by: java.lang.AssertionError: java.lang.Exception: Could not close incremental caches in…..

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.btapi.BuildToolsApiCompilationWork

java.lang.Exception: Could not close incremental caches in….

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.btapi.BuildToolsApiCompilationWork

java.lang.Exception: Could not close incremental caches…

这是 Kotlin 增量编译缓存损坏导致的构建失败(Could not close incremental caches),是环境缓存问题,不是代码问题。
多个插件(audioplayers/video_player/shared_preferences)的 Kotlin 编译在共享缓存上冲突,或上次构建中断留下了损坏缓存。

可以尝试清理再重建。
flutter clean
还是没成功

在 android/gradle.properties 里加了两个配置:
kotlin.incremental=false
kotlin.compiler.execution.strategy=in-process

禁用增量编译 + 改为进程内编译

可以解决问题。

  • Title: flutter安卓开发遇到的问题—— 2
  • Author: Anrola
  • Created at : 2026-08-14 18:36:40
  • Updated at : 2026-09-20 20:52:15
  • Link: https://redefine.ohevan.com/2026/08/14/flutter-debug-2/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
flutter安卓开发遇到的问题—— 2