30

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.

jbyen
  • 1,069
  • 1
  • 7
  • 20

7 Answers7

31

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.
jbyen
  • 1,069
  • 1
  • 7
  • 20
  • 7
    I would suggest using Android Studio provided jre as follows; org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home – Jona Nov 17 '20 at 20:04
  • @Jona, What would be the benefit of this other than consistent behaviour between the IDE and OS (e.g. Terminal)? Just curious, Thanks! – ddsultan Mar 07 '21 at 14:17
  • 1
    @ddsultan Android Studio provides its own JRE as you can see from the path I suggested. It's likely heavily tested by Google on every new Android Studio release. So that would be the primary reason for my suggestion. Hope that helps! – Jona Mar 08 '21 at 17:08
  • 1
    I'm curios, since gradle.properties normally isn't gitignored; wouldn't this change affect the entire team? Would it be better or possible to add this to local.properties instead? – MikeOscarEcho Mar 31 '21 at 19:57
  • @Jona in my case the path was different so following worked for me: `org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home/` – Slick Slime Nov 13 '21 at 06:38
28

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
Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
  • 2
    Combining this with another comment I am using `export JAVA_HOME=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home` to rely on the Android Studio bundled version. – Joshua Nov 19 '20 at 20:25
4

Solution of u problem -> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation

At last, here I found the solution.

I added jdk path

org.gradle.java.home=YOU_PATH_TO_JDK

to gradle.properties file and did a rebuild.

It works now.

WBLord
  • 874
  • 6
  • 29
  • 1
    I added this "org.gradle.java.home=/usr/local/java/jdk1.8.0_251" and I got an error. * What went wrong: Value '\usr\local\java\jdk1.8.0_251' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid). – jbyen Nov 13 '20 at 13:43
  • 2
    What`s editor u use (Idea\Android studio\VS)? Try fix u JAVA_HOME variable – WBLord Nov 13 '20 at 14:09
4

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
hot_gril
  • 89
  • 1
  • 3
  • This helped me after updating android studio. Thanks – Dazzle Jun 07 '21 at 10:10
  • Check Android Studio directory to check correct path. My path was and has worked for me: echo 'export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"' >> ~/.zshrc && source ~/.zshrc – Edeson Bizerril Nov 22 '21 at 18:08
4

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.

spekary
  • 408
  • 5
  • 10
0

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

Safdar Ali
  • 47
  • 5
-1

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.

RobC
  • 22,977
  • 20
  • 73
  • 80