Could not find tools.jar

出现的问题

将MAC OS 升级至11.1,安卓打包时报出错误

image.png

是因为升级之后JAVA_HOME 未进行配置。编译时找到了jre的目录,而目录则不包含tool.jar

解决方法

  1. 使用/usr/libexec/java_home -V查看JDK目录

image.png

设置JAVA_HOME:

vim ~/.zshrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

vim ~/.zshrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

2.把tools.jar复制到Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

sudo cp /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/tools.jar
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib
sudo cp /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/tools.jar
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib
  1. 重新下载最新JDK 8

参考链接