Flutter could not find tools.jar

Viewed 21945

Hi today I've upgrade my MacBook to macOS Big Sur version 11.0.1. Now there is a problem coming out.

* What went wrong:
Execution failed for task ':apple_sign_in:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

Anyone know how to solve this issue ? Thanks.

7 Answers

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.

Possible duplicate of https://stackoverflow.com/a/64864365/2405040.

You should not alter gradle.properties manually. Try setting your JAVA_HOME in ~/.bash_profile to something like-

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

then relaunch a terminal session or run

source ~/.bash_profile

If you are using Zsh/Oh-My-Zsh, add the above with file ~/.zshrc and then reload the same or relaunch the terminal-

source ~/.zshrc

I can't comment, but here's a macOS one-liner based on the other answers if you use ZSH (Catalina+ default). No need to install Java from Oracle.

echo 'export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"' >> ~/.zshrc && source ~/.zshrc

This issue is Mac specific and reading online it appears that often after updating the OS this problem will happen.

I resolved this by removing the following internet plugin:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin

Strange that this is what did it, but it worked for me.

In my case I use FVM and use Flutter 2.2.3

For Intel Mac users

go to Android -> gradle.properties

and add following at end of the file

org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home/

like this

I was facing this issue and the simple solution that worked for me was:

  1. Did a clean installation of jdk8 in mac and add the path to environmental variables (JAVA_HOME).

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Ho$
    
  2. Restarted the computer.

Related