I'm getting this error when I try to run a React Native template app:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':app'. The SDK directory '/home/[USER]/Android/Sdk' does not exist.
I've followed the Get Started Guide by React Native, step by step (https://facebook.github.io/react-native/docs/getting-started)
1. Installed this:
- brew install node
- brew install watchman
- brew tap AdoptOpenJDK/openjdk
- brew cask install adoptopenjdk8
2. And this:
npm install -g react-native-cli
3. Also did this:
Install Android Studio Download and install Android Studio. Choose a "Custom" setup when prompted to select an installation type. Make sure the boxes next to all of the following are checked:
Android SDK Android SDK Platform Performance (Intel ® HAXM) (See here for AMD) Android Virtual Device
I did it making sure to install these:
- Android 9 (Pie)
- Android SDK Platform 28
- Intel x86 Atom_64 System Image (AND) Google APIs Intel x86 Atom System Image
- Next, select the "SDK Tools" tab and check the box next to "Show Package Details" here as well. Look for and expand the "Android SDK Build-Tools" entry, then make sure that 28.0.3 is selected.
4. Then, I did this with vim $HOME/.bash_profile
Add the following lines to your $HOME/.bash_profile or $HOME/.bashrc config file:
- export ANDROID_HOME=$HOME/Library/Android/sdk
- export PATH=$PATH:$ANDROID_HOME/emulator
- export PATH=$PATH:$ANDROID_HOME/tools
- export PATH=$PATH:$ANDROID_HOME/tools/bin
- export PATH=$PATH:$ANDROID_HOME/platform-tools
(Do not copy paste the bullets)
BUT
I did not get this:
Type source $HOME/.bash_profile to load the config into your current shell. Verify that ANDROID_HOME has been added to your path by running echo $PATH.
When I do echo $PATH, I see this:
/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/hectorgonzalezsanchez/Library/Android/sdk/emulator:/Users/hectorgonzalezsanchez/Library/Android/sdk/tools:/Users/hectorgonzalezsanchez/Library/Android/sdk/tools/bin:/Users/hectorgonzalezsanchez/Library/Android/sdk/platform-tools
When I do vim $HOME/.bash_profile, I see this:
Setting PATH for Python 3.7 The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}" export PATH
Your previous /Users/hectorgonzalezsanchez/.bash_profile file was backed up as /Users/hectorgonzalezsanchez/.bash_profile.macports-saved_2019-08-15_at_13:26:28
MacPorts Installer addition on 2019-08-15_at_13:26:28: adding an appropriate PATH variable for use with MacPorts. export PATH="/opt/local/bin:/opt/local/sbin:$PATH" Finished adapting your PATH environment variable for use with MacPorts.
Adding ANDROID_HOME enviroment variable
- export ANDROID_HOME=$HOME/Library/Android/sdk
- export PATH=$PATH:$ANDROID_HOME/emulator
- export PATH=$PATH:$ANDROID_HOME/tools
- export PATH=$PATH:$ANDROID_HOME/tools/bin
- export PATH=$PATH:$ANDROID_HOME/platform-tools
(Do not copy paste the bullets)
When I do echo $HOME, I see this:
/Users/hectorgonzalezsanchez
I created an app:
react-native init FirstApp
And ran it with iOS:
'cd FirstApp react-native run-ios'
AND WAS SUCCESFUL (no problem in iPhone X with XCode)
BUT when I do:
'cd FirstApp' 'react-native run-android'
I get this error message:
What went wrong: A problem occurred configuring project ':app'. The SDK directory '/home/[USER]/Android/Sdk' does not exist.
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 2s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081