Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

android - app:compileDebugJavaWithJavac'. > Could not find tools.jar Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`

when I use this command in the terminal:

PS C:web devpractice-projects
eact-nativemyproject> react-native run-android --no-jetifier

I get this whole error:

info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
error 
Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.    
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warning 
14 actionable tasks: 2 executed, 12 up-to-date

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 FilesJavajre1.8.0_271 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 39s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details. 
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

My emulator isn't being launched and I have tried multiple fixes. I am getting started in react-native and don't understand the warnings or answers on similar questions. Please help.

question from:https://stackoverflow.com/questions/65643196/appcompiledebugjavawithjavac-could-not-find-tools-jar-failed-to-launch-emul

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are few ways you can run your app,

  1. Always works - Open the app from android studio. Select Open existing project and select android folder in your app to open the project and run from there after indexing is done.
  2. Not sure would work and not recommended (might need release build) but you can drag your apk file that is auto generated to your simulator to install.
  3. Add this line to gradle.properties file i.e. android/gradle.properties. org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home. replace the jdk version name or directory if required.

Note for mac - this is not library folder within your user directory so search them in your main drive location - should be something like machintosh hd

For windows - just replace the path after org.gradle.java.home=. Should be something like C:\Program Files\Java\jdk1.8.0_144


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...