Could not find tools.jar React Native Android In w

2020-05-22 07:21发布

guys . i just try to install react native in my laptop. i've followed all setup instruction but i stiil get those error .

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar

i used genymotion with os version 5.1.0, i've setup environment variable for android_home. Any idea what i miss here ?

sdk manager

10条回答
在下西门庆
2楼-- · 2020-05-22 07:33

If this problem occurs for Windows, then the solution here is fairly simple.

Install Chocolatey

Install jdk8

Restart Command Prompt or Powershell as Administrator, and run:

choco install jdk8

Now if you run

react-native run-android

This error shouldn't show up.

查看更多
beautiful°
3楼-- · 2020-05-22 07:35

Setting the missing "JAVA_HOME" system environment variable worked for me.

  • Press WIN+Pause on keyboard.
  • Click advanced system settings.
  • Click "Environment variables".
  • Click "New" under "System variables".
  • Type "JAVA_HOME" in the Variable name field.
  • Type the path to the JDK in the Value field. For me the correct path with short filename was "C:\PROGRA~1\Java\jdk1.8.0_66". Your path will vary depending on the installed version.
  • Click OK, and OK in previous window too.
  • Restart any command prompts or restart the computer.
  • react-native run-android worked fine after that.
查看更多
Luminary・发光体
4楼-- · 2020-05-22 07:35

If you have the Android Studio embedded JDK, then it may cause conflicts. A workaround for this problem I've found is setting your JAVA_HOME to the default JDK location specified in Android Studio.

  1. Open Android Studio
  2. Press Ctrl+Alt+Shift+S to open Project Structure window.
  3. Set your JAVA_HOME environment variable to the path specified under "JDK location".
查看更多
甜甜的少女心
5楼-- · 2020-05-22 07:40

Find and copy tool.jar from JDK path C:\Program Files\Java\jdk1.8.0_151\lib\tool.jar

then paste it in JRE folder C:\Program Files\Java\jre1.8.0_181\lib

then delete build folder from your project/android/app/=>build

and then try react-native run-android

查看更多
做个烂人
6楼-- · 2020-05-22 07:42

I had the same problem while running react-native run-android it gave me the error tool.jar not found. i solved this by adding a single line mentioned below, in gradle.properties file which is in android project. enter image description here org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_121

查看更多
够拽才男人
7楼-- · 2020-05-22 07:42

I know this question is for Windows, but this is the first result for this error on Google, so for Linux this problem could be fixed with:

sudo apt install default-jdk

查看更多
登录 后发表回答