Could not find tools.jar React native Android in Mac OSX

I reach this step :

reactive-native run-android ; 

When I run echo $JAVA_HOME, i got the full path to JDK directory :

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

I add that path to ./android/gradle.properties :

org.gradle.java.home=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/

I got the same error which is :

..... .... :app:generateDebugSources UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    Could not find tools.jar

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

.....


Solution 1:

This error pops up, when some plugins of react-native like masked-view unable to locate tools.jar path in your machine which exists inside JDK home lib directory.

With respect to this question, what you did is almost right but you added the Internet Plugins path which is incorrect. You have to add the jdk path of your machine.

Locate JDK path :

If your JAVA_HOME variable exists then you can find directly via terminal using vim .zshrc or vim .bashrc command where must exists a path similar to /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk{Your Machine JDK Version}/Contents/Home (Copy this JAVA_HOME path)

After getting path of JDK, under android folder in gradle.properties file add this line

org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk{"REPLACE_IT_WITH_YOUR_JDK_VERSION"}/Contents/Home

Hope this will help you or somebody else!

Thanks :)

Solution 2:

You should download JDK, finish the installation and add lib's path to PATH. In my case:

/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/lib

It's at the same level with bin, which is:

/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/bin