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

Flutter启动模拟器应用报错:无法找到有效javaHome路径

Flutter模拟器运行初始应用失败:JavaHome路径异常解决记录

问题概述

Flutter搭配Android Studio Electric Eel开发,时隔一月后在VS Code启动初始应用时,Gradle构建失败,提示指定的JavaHome路径无效,系统识别的路径为C:\Program Files\Java\jre-10.0.2\bin\java.exe,但Android Studio实际安装在Z:\Program Files\Android\Android Studio。

报错信息

PS E:\projects\first_app> flutter run
Using hardware rendering with device sdk gphone x86 64. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 64 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jre-10.0.2\bin\java.exe

* 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
Running Gradle task 'assembleDebug'...                           1,010ms
Exception: Gradle task assembleDebug failed with exit code 1

无效尝试

  • 手动将C:\Program Files\Java\jdk-19内容复制到JRE文件夹,虽能临时解决构建问题,但会覆盖其他应用依赖的JRE,存在兼容性风险
  • 新增或修改系统环境变量JAVA_HOME指向正确JDK路径,无效果

有效解决步骤

  1. 使用Revo卸载工具彻底清理系统中所有Java版本(包括各类JDK、JRE)
  2. 重新安装Java 8版本
  3. 重新执行flutter run命令,应用可正常在模拟器启动

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 04:43:16