L'exécution a échoué pour la tâche ':app:compileDebugJavaWithJavac'. > Impossible de trouver tools.jar
J'obtiens cette erreur lors de l'exécution
react-native run-android
J'ai essayé de copier le fichier tools.jar dans l'emplacement d'installation de JRE, réinstallé JDK et JRE, vérifié les variables d'environnement pour le chemin. Rien n'a fonctionné.
Il est revenu avec l'exception ci-dessous
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files (x86)\Java\jre1.8.0_211 contains a valid JDK installation
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Solution du problème
Pour MacOS, voici les étapes :
$ java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
$ cd /Library/Java/JavaVirtualMachines
$ ls
total 0
drwxr-xr-x 3 root wheel 96B 24 Out 09:24 adoptopenjdk-15-openj9.jre
drwxr-xr-x 3 root wheel 96B 30 Dez 20:18 jdk1.8.0_271.jdk
$ cd jdk1.8.0_271.jdk/Contents/Home
Remarque: si vous ne trouvez pas 1.8.0_271.jdk
après avoir répertorié les fichiers dans le dossier, vous pouvez trouver un autre fichier jdk comme celui- adoptopenjdk-8.jdk
ci, utilisez-le.
$ pwd | pbcopy
org.gradle.java.home=<path_to_current_java_home>
Commentaires
Enregistrer un commentaire