React Native无法识别Java JDK。

huangapple 未分类评论50阅读模式
英文:

react native does not identify java JDK

问题

我目前正在开发一个原生应用程序。但是当我尝试启动应用程序时,npx给了我一个错误。
JAVA_HOME设置为无效目录:/usr/lib/jvm/java-8-openjdk-amd64

info 正在运行jetifier以将库迁移到AndroidX。您可以使用“--no-jetifier”标志禁用它。
Jetifier找到960个文件需要进行转换。使用4个工作线程进行转换...
info 正在启动JS服务器...
warn 无法自动启动打包服务器。请手动运行“react-native start”。错误详情:EACCES:权限被拒绝,打开'/home/noobmaster/Desktop/mkFirstReactNativeAndroidAPP/AwesomeProject/node_modules/react-native/scripts/.packager.env'
/bin/sh:1:adb:未找到命令
info 正在启动模拟器...
error 启动模拟器失败。原因:没有发现模拟器作为“emulator -list-avds”的输出。
warn 请手动启动模拟器或连接设备。否则应用可能无法启动。
info 正在安装应用程序...

错误:JAVA_HOME设置为无效目录:/usr/lib/jvm/java-8-openjdk-amd64

请在环境变量中设置JAVA_HOME变量,以匹配Java安装的位置。

error 安装应用程序失败。确保您已经设置好Android开发环境:https://reactnative.dev/docs/getting-started.html#android-development-environment。可以通过--verbose标志运行CLI以获取更多详细信息。
错误:命令失败:./gradlew app:installDebug -PreactNativeDevServerPort=8081

    at makeError (/home/noobmaster/Desktop/mkFirstReactNativeAndroidAPP/AwesomeProject/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/home/noobmaster/Desktop/mkFirstReactNativeAndroidAPP/AwesomeProject/node_modules/execa/index.js:278:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

这只发生在react-native中。当我编译一个Java文件或运行Android应用程序时,我不会遇到任何关于找不到JDK的问题。

我的JAVA_HOME是
/usr/lib/jvm/java-8-openjdk-amd64

英文:

I am currently working on a native app. But when I try to start the application npx give me an error.
JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-openjdk-amd64

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
warn Failed to automatically start the packager server. Please run "react-native start" manually. Error details: EACCES: permission denied, open '/home/noobmaster/Desktop/mkFirstReactNativeAndroidAPP/AwesomeProject/node_modules/react-native/scripts/.packager.env'
/bin/sh: 1: adb: not found
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...

ERROR: JAVA_HOME is set to an invalid directory:  /usr/lib/jvm/java-8-openjdk-amd64

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.


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

    at makeError (/home/noobmaster/Desktop/mkFirstReactNativeAndroidAPP/AwesomeProject/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/home/noobmaster/Desktop/mkFirstReactNativeAndroidAPP/AwesomeProject/node_modules/execa/index.js:278:16)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)


This is only happens with react-native. When I compile a java file or run android application I don't get any problems with finding JDK.

my JAVA_HOME is
/usr/lib/jvm/java-8-openjdk-amd64

huangapple
  • 本文由 发表于 2020年4月4日 23:45:19
  • 转载请务必保留本文链接:https://java.coder-hub.com/61030613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定