123456:rndemo2 ule_zhangfanglin$ react-native run-android
Scanning 556 folders for symlinks in /Users/admin/Desktop/RN学习/08/rndemo2/node_modules (7ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
ERROR: JAVA_HOME is set to an invalid directory: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
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
123456:rndemo2 ule_zhangfanglin$ cat ~/.profile
Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session as a function
123456:rndemo2 ule_zhangfanglin$ JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
123456:rndemo2 ule_zhangfanglin$ export JAVA_HOME
123456:rndemo2 ule_zhangfanglin$ react-native run-android
FAILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring project ':app'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
==========>
123456:rndemo2 ule_zhangfanglin$ touch .bash_profile
123456:rndemo2 ule_zhangfanglin$ open .bash_profile
123456:rndemo2 ule_zhangfanglin$ source .bash_profile
123456:rndemo2 ule_zhangfanglin$ react-native run-android
======>
export ANDROID_HOME=/Users/admin/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
======>