forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate-android-test-env.sh
executable file
·97 lines (85 loc) · 3.71 KB
/
validate-android-test-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# This script validates that Android is set up correctly for the
# testing environment.
#
# In particular, the config in ReactAndroid/build.gradle must match
# the android sdk that is actually installed. Also, we must have the
# right version of Java.
# Check that Buck is working.
if [ -z "$(which buck)" ]; then
echo "You need to install Buck."
echo "See https://buckbuild.com/setup/install.htm for instructions."
exit 1
fi
if [ -z "$(buck --version)" ]; then
echo "Your Buck install is broken."
if [ -d "/opt/facebook" ]; then
SUGGESTED="b9b76a3a5a086eb440a26d1db9b0731875975099"
echo "FB laptops ship with a Buck config that is not compatible with open "
echo "source. FB Buck requires the environment to set a buck version, but "
echo "the open source version of Buck forbids that."
echo
echo "You can try setting:"
echo
echo "export BUCKVERSION=${SUGGESTED}"
echo
echo "in your .bashrc or .bash_profile to fix this."
echo
echo "If you don't want to alter BUCKVERSION for other things running on"
echo "your machine, you can just scope it to a single script, for example"
echo "by running something like:"
echo
echo "BUCKVERSION=${SUGGESTED} $0"
echo
else
echo "I don't know what's wrong, but calling 'buck --version' should work."
fi
exit 1
fi
# BUILD_TOOLS_VERSION is in a format like "23.0.1"
BUILD_TOOLS_VERSION=`grep buildToolsVersion $(dirname $0)/../ReactAndroid/build.gradle | sed 's/^[^"]*\"//' | sed 's/"//'`
# MAJOR is something like "23"
MAJOR=`echo $BUILD_TOOLS_VERSION | sed 's/\..*//'`
# Check that we have the right major version of the Android SDK.
PLATFORM_DIR="$ANDROID_HOME/platforms/android-$MAJOR"
if [ ! -e "$PLATFORM_DIR" ]; then
echo "Error: could not find version $ANDROID_VERSION of the Android SDK."
echo "Specifically, the directory $PLATFORM_DIR does not exist."
echo "You probably need to specify the right version using the SDK Manager from within Android Studio."
echo "See https://facebook.github.io/react-native/docs/getting-started.html for details."
exit 1
fi
# Check that we have the right version of the build tools.
BT_DIR="$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION"
if [ ! -e "$BT_DIR" ]; then
echo "Error: could not find version $BUILD_TOOLS_VERSION of the Android build tools."
echo "Specifically, the directory $BT_DIR does not exist."
echo "You probably need to explicitly install the correct version of the Android SDK Build Tools from within Android Studio."
echo "See https://facebook.github.io/react-native/docs/getting-started.html for details."
exit 1
fi
if [ -n "$(which csrutil)" ]; then
# This is a SIP-protected machine (recent OSX).
# Check that we are not using SIP-protected Java.
JAVA=`which java`
if [ "$JAVA" = "/usr/bin/java" ]; then
echo "Error: we can't use this Java version."
echo "Currently, Java runs from $JAVA."
echo "The operating-system-provided Java doesn't work with React Native because of SIP protection."
echo "Please install the Oracle Java Development Kit 8."
if [ -d "/opt/facebook" ]; then
echo "See https://our.intern.facebook.com/intern/dex/installing-java-8/ for instructions on installing Java 8 on FB laptops."
else
echo "Check out http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ."
echo "Be sure that you set JAVA_HOME and PATH correctly."
fi
echo "After installing Java, run 'buck kill' and 'buck clean'."
exit 1
fi
fi
if [ -z "$JAVA_HOME" ]; then
echo "Error: \$JAVA_HOME is not configured."
echo "Try adding export JAVA_HOME=\$(/usr/libexec/java_home) to your .bashrc or equivalent."
echo "You will also want to add \$JAVA_HOME/bin to your path."
exit 1
fi