Created
April 2, 2024 04:20
-
-
Save Neelansh-ns/29ffa195c8e6799e34ffc5a14e7b5215 to your computer and use it in GitHub Desktop.
A shell script to download the NDK version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Define the NDK version you want to download | |
| NDK_VERSION="r26c" | |
| NDK_VERSION_INT="26.2.11394342" | |
| # Define the NDK download URL | |
| NDK_URL="https://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-darwin.zip" | |
| # Define the directory where you want to download and extract the NDK | |
| NDK_DIR="$HOME/Library/Android/sdk/ndk" | |
| # Check if the NDK directory already exists | |
| if [ ! -d "$NDK_DIR" ]; then | |
| echo "NDK directory not found. Creating..." | |
| mkdir -p "$NDK_DIR" | |
| fi | |
| # Check if the NDK zip file already exists in the NDK directory | |
| if [ ! -f "$NDK_DIR/zip/android-ndk-${NDK_VERSION}-darwin.zip" ]; then | |
| echo "NDK Zip file not found. Downloading..." | |
| # Download the NDK zip file | |
| wget -P "$NDK_DIR/zip" "$NDK_URL" | |
| echo "NDK zip file downloaded successfully." | |
| else | |
| echo "NDK zip file already exists. Skipping download." | |
| fi | |
| # Unzip the NDK zip file | |
| echo "Extracting NDK..." | |
| unzip -q "$NDK_DIR/zip/android-ndk-${NDK_VERSION}-darwin.zip" -d "$NDK_DIR" | |
| # Rename the extracted NDK folder | |
| mv "$NDK_DIR/android-ndk-${NDK_VERSION}" "$NDK_DIR/${NDK_VERSION_INT}" | |
| # Remove the downloaded zip file | |
| echo "Removing downloaded NDK zip file..." | |
| rm -rf "$NDK_DIR/zip" | |
| # Add the NDK path to the .zshrc file | |
| echo "export ANDROID_NDK_HOME=$NDK_DIR/${NDK_VERSION_INT}" >> ~/.zshrc | |
| echo "export PATH=\$PATH:\$ANDROID_NDK_HOME" >> ~/.zshrc | |
| echo "NDK path added to .zshrc file." | |
| source $HOME/.zshrc | |
| echo "NDK setup complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment