Could Not Find Tools.Jar. Please Check That C:\Program Files\Java\Jre1.8.0_151 Contains a Valid Jdk Installation

Could not find tools.jar

Looks like it's looking for a JDK while you're pointing to a JRE. Do you have an installed JDK? If so, maybe try pointing to that.

Flutter could not find tools.jar

THREAD CLOSED

I'm a Mac user. I've found the solution by using this method.

  1. Go to your android folder > Gradle.properties > add your jdk path.
// Example 
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home

  1. Clean and rebuild then it's done.

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

The problem is that with the update the built-in java took precedence and it doesn't have the SDK because it's just the runtime.

You just need to change your java home and add the java binary to your .zshrc
to find your java home execute:

/usr/libexec/java_home -V | grep jdk

the output should be similar to the following:

Matching Java Virtual Machines (1):
1.8.0_272 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

you should take the path from the one that says SDK in my case

/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

after that, you just add the following to the end of your .zshrc that should be in your home.

You can edit it with (if you decide to use vim you can exit writing :wq! and pressing enter)

vim .zshrc

add the following:

export JAVA_HOME=the/path/you/copied/before
export PATH=$JAVA_HOME/bin:$PATH

where the/path/you/copied/before in my case would be

/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

save the file and close all your terminals and open them again.

If while editing .zshrc file getting error ".zshrc" E212: Can't open file for writing
then use sudo vim.zshrc and you'll be able to edit.

The error should be solved.

Edit

Instead of ~/.zshrc, you could have ~/.bash_profile or ~/.bash_rc so edit yours accordingly

Ionic + Cordova Android build error - could not find tools.jar

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-

  1. Flutter could not find tools.jar
  2. Not able to run Eclipse on macOS Big Sur

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.



Related Topics



Leave a reply



Submit