Mac电脑 Flutter在Android设备运行报错: Could not find tools.jar. Please check that /Library/Internet Plug-I...

Launching lib/main.dart on Redmi K30 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':alipay_kit:compileVendorDebugJavaWithJavac'.

Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

  • 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

BUILD FAILED in 35s
Exception: Gradle task assembleDebug failed with exit code 1

试了各种方法都没解决,最终重新安装了Java,下载地址,
下载后查看Java安装目录: /usr/libexec/java_home -V
打印如下:

wf@localhost ~ % /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.321.07 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_321 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home/lib 目录下的tools.jar 拷贝到 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

重新运行就可以了。

你可能感兴趣的:(Mac电脑 Flutter在Android设备运行报错: Could not find tools.jar. Please check that /Library/Internet Plug-I...)