我正在开发MacOS,并且刚刚开始使用react-native
。
开始的第一步是运行:react-native run-android
或react-native run-ios
。但是我得到了这个错误:
react-native run-android
结果:
Scanning folders for symlinks in /Users/ric/myprojs/albums/node_modules (6ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
这是我在运行java --version
时得到的结果
java --version
结果:
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
mbp:albums ric$ java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
编辑
我的javac版本:
javac --version
结果:
javac 9.0.1
有什么办法解决这个问题吗?
发布于 2017-10-23 18:11:16
解决这个错误最快的方法就是使用JDK8,除非你真的需要使用JDK9。
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
不要忘记将环境变量JAVA_HOME更改为新的JDK版本!
发布于 2017-11-03 18:41:25
确保已安装JDK8
,然后将JAVA_HOME
设置为JDK8
例如:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
或使用.bash_*
文件设置此变量
发布于 2018-08-15 12:57:12
vi ~/.bash_profile
然后添加以下行:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
现在生成文件,使上述更改在当前shell中生效:
source ~/.bash_profile
https://stackoverflow.com/questions/46867399
复制相似问题