Last active
December 15, 2024 19:34
-
-
Save wathika-eng/7b92d5661dbf7c59fe1c9caac7e1ae4c to your computer and use it in GitHub Desktop.
Setup Script for Android SDK and Flutter Toolchain on Linux
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 | |
# Step 1: Install required dependencies | |
echo "Installing required packages..." | |
sudo apt update | |
sudo apt install -y openjdk-11-jdk wget curl unzip cmake ninja-build | |
# Step 2: Install Android SDK Command-Line Tools | |
echo "Installing Android SDK Command-Line Tools..." | |
# Download the latest Android SDK command-line tools | |
SDK_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip" | |
wget $SDK_TOOLS_URL -O sdk-tools.zip | |
# Create the SDK directory | |
mkdir -p $HOME/Android/Sdk/cmdline-tools | |
# Extract SDK Command-Line Tools | |
unzip sdk-tools.zip -d $HOME/Android/Sdk/cmdline-tools | |
# Make the extracted directory structure compatible | |
mv $HOME/Android/Sdk/cmdline-tools/cmdline-tools $HOME/Android/Sdk/cmdline-tools/latest | |
# Accept the SDK licenses | |
$HOME/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --licenses | |
# Step 3: Install NDK and other SDK components (platform-tools, build tools, etc.) | |
echo "Installing Android NDK and platform tools..." | |
$HOME/Android/Sdk/cmdline-tools/latest/bin/sdkmanager "ndk;21.4.7075529" "platform-tools" "build-tools;30.0.3" | |
# Step 4: Set up Android SDK environment variables | |
echo "Setting up Android SDK environment variables..." | |
# Define SDK path | |
ANDROID_SDK_PATH=$HOME/Android/Sdk | |
# Add environment variables for the SDK | |
echo "export ANDROID_HOME=$ANDROID_SDK_PATH" >> ~/.bashrc | |
echo "export PATH=\$PATH:\$ANDROID_HOME/tools:\$ANDROID_HOME/platform-tools:\$ANDROID_HOME/cmdline-tools/latest/bin" >> ~/.bashrc | |
# Reload bashrc to apply changes | |
source ~/.bashrc | |
# Step 5: Install Flutter via the webi.sh script | |
echo "Installing Flutter using the webi.sh script..." | |
curl -sS https://webi.sh/flutter | sh | |
# Add Flutter to the system PATH | |
echo "export PATH=\$PATH:\$HOME/.webi/flutter/bin" >> ~/.bashrc | |
source ~/.bashrc | |
# Step 6: Update Flutter configuration for Android SDK | |
flutter config --android-sdk $ANDROID_SDK_PATH | |
# Step 7: Run flutter doctor to check for issues | |
flutter doctor | |
echo "Android SDK, NDK, Flutter, cmake, and ninja setup completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the script to install the Android toolchain without Android Studio.
I would like to note
Line 6: openjdk-11-jdk on current Debian (12.8) is no longer available via default package manager. openjdk-17 is the default for Debian 12.8.
Line 39: $ANDROID_HOME/tools does not exist. Do you mean $ANDROID_HOME/build-tools/35.0.0 ?