diff --git a/scripts/lib/setup/installers.sh b/scripts/lib/setup/installers.sh index 3c6c35ff18..599722bddd 100755 --- a/scripts/lib/setup/installers.sh +++ b/scripts/lib/setup/installers.sh @@ -156,6 +156,8 @@ function install_android_sdk() { elif is_linux; then install_android_sdk_linux fi + + use_android_sdk } function install_android_sdk_linux() { @@ -290,3 +292,42 @@ function dependency_setup() { echo " + done" echo } + +function use_android_sdk() { + _localPropertiesPath=./android/local.properties + if [ -n "$ANDROID_SDK" ]; then + if ! grep -Fq "sdk.dir" $_localPropertiesPath; then + echo "sdk.dir=$ANDROID_SDK" | tee -a $_localPropertiesPath + fi + else + _docURL="https://docs.status.im/docs/build_status_linux.html" + if is_macos; then + _docURL="https://docs.status.im/docs/build_status_osx.html" + fi + cecho "@yellow[[ANDROID_SDK environment variable not defined, please install the Android SDK.]]" + cecho "@yellow[[(see $_docUrl).]]" + + echo + + exit 1 + fi +} + +function install_android_ndk() { + _localPropertiesPath=./android/local.properties + if grep -Fq "ndk.dir" $_localPropertiesPath; then + dependency_setup \ + "pushd android && ./gradlew react-native-android:installArchives && popd" + else + _ndkParentDir=~/Android/Sdk + mkdir -p $_ndkParentDir + cecho "@cyan[[Downloading Android NDK.]]" + wget --output-document=android-ndk.zip https://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip && \ + cecho "@cyan[[Extracting Android NDK to $_ndkParentDir.]]" && \ + unzip -q -o android-ndk.zip -d "$_ndkParentDir" && \ + rm -f android-ndk.zip && \ + _ndkTargetDir="$_ndkParentDir/$(ls $_ndkParentDir | head -n 1)" && \ + echo "ndk.dir=$_ndkTargetDir" | tee -a $_localPropertiesPath && \ + cecho "@blue[[Android NDK installation completed in $_ndkTargetDir.]]" + fi +} \ No newline at end of file diff --git a/scripts/setup b/scripts/setup index 0ec1d5ebca..5b795313b7 100755 --- a/scripts/setup +++ b/scripts/setup @@ -31,6 +31,7 @@ install_node install_watchman install_react_native_cli install_android_sdk +install_android_ndk install_maven install_cocoapods @@ -49,6 +50,6 @@ dependency_setup ./re-natal enable-source-maps dependency_setup \ "mvn -f modules/react-native-status/ios/RCTStatus/pom.xml dependency:unpack" -using_cocoapods && dependency_setup "cd ios && pod install && cd .." +using_cocoapods && dependency_setup "pushd ios && pod install && popd" setup_complete