1#!/bin/bash 2# Copyright (c) Meta Platforms, Inc. and affiliates. 3# 4# This source code is licensed under the MIT license found in the 5# LICENSE file in the root directory of this source tree. 6 7# This script validates that the Android SDK is installed correctly. 8# This means setting ANDROID_HOME and adding its subdirectories to PATH. 9# If the Android SDK is not installed correctly, this script exits 10# with an error and a helpful message is printed. 11 12if [ -z "$ANDROID_HOME" ]; then 13 echo "Error: \$ANDROID_HOME is not configured." 14 echo "You must first install the Android SDK and then set \$ANDROID_HOME." 15 echo "If you already installed the Android SDK, the problem is that you need to export ANDROID_HOME from your .bashrc or equivalent." 16 echo "See https://reactnative.dev/docs/getting-started for instructions." 17 exit 1 18fi 19 20if [ ! -d "$ANDROID_HOME" ]; then 21 echo "Error: \$ANDROID_HOME = $ANDROID_HOME but that directory does not exist." 22 echo "It is possible that you installed then uninstalled the Android SDK." 23 echo "In that case, you should reinstall it." 24 echo "See https://reactnative.dev/docs/getting-started for instructions." 25 exit 1 26fi 27 28if [ ! -e "$ANDROID_HOME/tools/emulator" ]; then 29 echo "Error: could not find an emulator at \$ANDROID_HOME/tools/emulator." 30 echo "Specifically, $ANDROID_HOME/tools/emulator does not exist." 31 echo "This indicates something is broken with your Android SDK install." 32 echo "One possibility is that you have \$ANDROID_HOME set to the wrong value." 33 echo "If that seems correct, you might want to try reinstalling the Android SDK." 34 echo "See https://reactnative.dev/docs/getting-started for instructions." 35 exit 1 36fi 37 38if [ -z `which emulator` ]; then 39 echo "Error: could not find 'emulator'. Specifically, 'which emulator' was empty." 40 echo "However, the emulator seems to be installed at \$ANDROID_HOME/tools/emulator already." 41 echo "This means that the problem is that you are not adding \$ANDROID_HOME/tools to your \$PATH." 42 echo "You should do that, and then rerun this command." 43 echo "Sorry for not fixing this automatically - we just didn't want to mess with your \$PATH automatically because that can break things." 44 exit 1 45fi 46 47if [ -z `which adb` ]; then 48 echo "Error: could not find 'adb'. Specifically, 'which adb' was empty." 49 echo "This indicates something is broken with your Android SDK install." 50 echo "The most likely problem is that you are not adding \$ANDROID_HOME/platform-tools to your \$PATH." 51 echo "If all else fails, try reinstalling the Android SDK." 52 echo "See https://reactnative.dev/docs/getting-started for instructions." 53 exit 1 54fi 55