today I've upgrade my MacBook to macOS Big Sur version 11.0.1. Now there is a problem coming out when I tried to build the project for Android.
Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
Try running
/usr/libexec/java_home -V
And see if this shows in the list
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
This was the case for me and I had to remove the entries to the Internet Plug-Ins folder. Check here for more details that helped me.
I also faced the same issue today while the same setup (building the Android app) was working for me before upgrading to Big Sur.
I saw various solutions like-
But I was not sure if those were recommended solution. I tried for few hours and finally got it working with the correct fix (looks to me).
Basically, for me, the JAVA_HOME
variable was not set (or Big Sur removed it somehow).
So I simply added it in my ~/.zshrc
(or ~/.bashrc
)-
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
You can simply check and replace the version number in the above line.
If this is not still resolved for the Cordova android build -- just do it manually. My case: java_home is set properly and also reloaded ~/.zshrc (or ~/.bashrc) files. And I am getting JAVA_HOME value by echoing on terminal.
So I manually copied file tool.jar from /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib
to
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib
And It worked.
For ease use this cmd
sudo cp /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/tools.jar /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib
Just check your JAVA JDK version.
The issue happens because of the environment variable JAVA_HOME
is not correctly set.
Step 1 - Confirm that you have issue with JAVA_HOME
by printing its value in the terminal. You will most likely get an empty string.
echo $JAVA_HOME
Step 2 - Find the correct path on your machine
/usr/libexec/java_home -V
Copy that path associated with "Java SE 8" which usually looks like /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
Step 3 - Edit .zshenv
using nano
nano ~/.zshenv
Step 4 - Add the path from step 2 to the file as follows
export JAVA_HOME=YOUR_JAVA_PATH
example:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
Step 5 - Source the updated .zshenv
file to activate the environment variable
source ~/.zshenv
Step 6 - Print to confirm the path
echo $JAVA_HOME
After updating Mac Os to Big Sur I faced the same problem, Solution :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With