├── README.md ├── android-studio.desktop ├── flutter.fish ├── flutterrc ├── install.fish ├── install.sh └── sdkmanager.sh /README.md: -------------------------------------------------------------------------------- 1 | ## Notes 2 | _This script will install android sdk and flutter sdk on ~/Android. If you select install with Android Studio, Android Studio will installed on /opt/android-studio_ 3 | 4 | # Flutter installer 5 | 6 | ## Requirements 7 | Arch linux based OS (Pacman). 8 | 9 | Debian 11 based OS, Ubuntu 20.04 LTS based OS or newer (APT). 10 | 11 | 18 | bash, zsh or fish shell. 19 | 20 | ## To Install 21 | 22 | 1. Clone this repository and run install.sh 23 | 24 | ``` 25 | git clone https://github.com/wildan-pratama/flutter-install.git 26 | cd flutter-install 27 | 28 | ./install.sh 29 | ``` 30 | 31 | 2. Follow step installation on script 32 | 33 | ![image](https://user-images.githubusercontent.com/84622086/233557218-89b775bf-59c6-4f1f-9006-33fe9cf6dc0c.png) 34 | 35 | 36 | ## After installation 37 | 38 | If you want change your shell, you must put your path manualy 39 | 40 | 41 | ``` 42 | # from fish to bash/zsh 43 | ## add this line to your .bashrc or .zshrc, if already exits you can skip 44 | source $HOME/Android/flutterrc 45 | 46 | # from bash/zsh to fish 47 | ## add this line to ~/.config/fish/config.fish, if already exits you can skip 48 | source $HOME/Android/flutter.fish 49 | ``` 50 | 51 | You can set browser for flutter web on ~Android/flutterrc or ~/Android/flutter.fish 52 | 53 | 54 | ``` 55 | # fish 56 | ## remove comment (#) and edit this line on ~/Android/flutter.fish 57 | set -x CHROME_EXECUTABLE "/path/to/your/browser" 58 | 59 | # bash/zsh 60 | ## remove comment (#) and edit this line on ~Android/flutterrc 61 | export CHROME_EXECUTABLE="/path/to/your/browser" 62 | ``` 63 | 64 | If you want install AVD witout Android Studio you can install emulator 65 | 66 | 67 | ``` 68 | # Install emulator 69 | sdkmanager --install emulator 70 | 71 | # For more instruction about emulator you can tipe --help 72 | emulator --help 73 | 74 | # Example for installing a emulator 75 | ## Search system image you want install 76 | sdkmanager --list 77 | ## Download system image, exp: 78 | sdkmanager --install "system-images;android-33;google_apis_playstore;x86_64" 79 | ## Create Emulator 80 | avdmanager create avd -n Emulatorname -k "system-images;android-33;google_apis_playstore;x86_64" --device "pixel" 81 | ## Exp to start Emulator with gpu and 2048MB memory 82 | emulator -avd Emulatorname -gpu host -memory 2048 83 | ``` 84 | -------------------------------------------------------------------------------- /android-studio.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Android Studio 5 | Exec=/opt/android-studio/bin/studio.sh 6 | Icon=/opt/android-studio/bin/studio.png 7 | Terminal=false 8 | Categories=Utility;Development; 9 | -------------------------------------------------------------------------------- /flutter.fish: -------------------------------------------------------------------------------- 1 | ## SDK exporting 2 | set -x ANDROID_HOME "$HOME/Android" 3 | set -x ANDROID_SDK_ROOT "$ANDROID_HOME/sdk" 4 | 5 | ## Tools exporting 6 | set -x PATH $ANDROID_SDK_ROOT/cmdline-tools/latest/bin $PATH 7 | set -x PATH $ANDROID_SDK_ROOT/emulator $PATH 8 | set -x PATH $ANDROID_SDK_ROOT/platform-tools $PATH 9 | 10 | ## Flutter binary exporting 11 | set -x PATH $ANDROID_HOME/flutter/bin $PATH 12 | 13 | ## Androidstudio binary exporting 14 | if test -d /opt/android-studio/bin 15 | set -x PATH /opt/android-studio/bin $PATH 16 | end 17 | 18 | ## Fix problems with Java apps 19 | #set -x wmname "LG3D" 20 | set -x _JAVA_AWT_WM_NONREPARENTING "1" 21 | 22 | ## Browser exporting for web dev 23 | #set -x CHROME_EXECUTABLE "brave" 24 | -------------------------------------------------------------------------------- /flutterrc: -------------------------------------------------------------------------------- 1 | # 2 | # Installation: 3 | # 4 | # Via shell config file ~/.bashrc (or ~/.zshrc) 5 | # 6 | # Append the contents to config file 7 | # 'source' the file in the config file 8 | # 9 | # You may also have a directory on your system that is configured 10 | # for completion files, such as: 11 | # 12 | # /usr/local/etc/bash_completion.d/ 13 | 14 | ###-begin-flutter-completion-### 15 | 16 | if type complete &>/dev/null; then 17 | __flutter_completion() { 18 | local si="$IFS" 19 | IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \ 20 | COMP_LINE="$COMP_LINE" \ 21 | COMP_POINT="$COMP_POINT" \ 22 | flutter completion -- "${COMP_WORDS[@]}" \ 23 | 2>/dev/null)) || return $? 24 | IFS="$si" 25 | } 26 | complete -F __flutter_completion flutter 27 | elif type compdef &>/dev/null; then 28 | __flutter_completion() { 29 | si=$IFS 30 | compadd -- $(COMP_CWORD=$((CURRENT-1)) \ 31 | COMP_LINE=$BUFFER \ 32 | COMP_POINT=0 \ 33 | flutter completion -- "${words[@]}" \ 34 | 2>/dev/null) 35 | IFS=$si 36 | } 37 | compdef __flutter_completion flutter 38 | elif type compctl &>/dev/null; then 39 | __flutter_completion() { 40 | local cword line point words si 41 | read -Ac words 42 | read -cn cword 43 | let cword-=1 44 | read -l line 45 | read -ln point 46 | si="$IFS" 47 | IFS=$'\n' reply=($(COMP_CWORD="$cword" \ 48 | COMP_LINE="$line" \ 49 | COMP_POINT="$point" \ 50 | flutter completion -- "${words[@]}" \ 51 | 2>/dev/null)) || return $? 52 | IFS="$si" 53 | } 54 | compctl -K __flutter_completion flutter 55 | fi 56 | 57 | ###-end-flutter-completion-### 58 | 59 | ## SDK exporting 60 | export ANDROID_HOME="$HOME/Android" 61 | export ANDROID_SDK_ROOT="$ANDROID_HOME/sdk" 62 | 63 | ## Tools exporting 64 | export PATH="$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin" 65 | export PATH="$PATH:$ANDROID_SDK_ROOT/emulator" 66 | export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools" 67 | 68 | ## Flutter binary exporting 69 | export PATH="$PATH:$ANDROID_HOME/flutter/bin" 70 | 71 | ## Androidstudio binary exporting 72 | if [ -d /opt/android-studio ]; then 73 | export PATH="$PATH:/opt/android-studio/bin" 74 | fi 75 | 76 | ## Fix problems with Java apps 77 | #export wmname="LG3D" 78 | export _JAVA_AWT_WM_NONREPARENTING=1 79 | 80 | ## Browser exporting for web dev 81 | #export CHROME_EXECUTABLE="brave" 82 | -------------------------------------------------------------------------------- /install.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | source flutter.fish 4 | echo 5 | echo "This script will install package required by Flutter and will download required sdk to $ANDROID_HOME" 6 | echo 7 | 8 | # Read Input 9 | echo "Continue? [Yes/yes/Y/y/No/no/N/n]: " 10 | read confirm 11 | 12 | # Proccesing input 13 | switch $confirm 14 | case "Yes" "yes" "Y" "y" 15 | 16 | # Select channel 17 | set -x channel "stable" 18 | echo 19 | echo "Please slect flutter channel you want install:" 20 | echo "1. Stable (default, updated quarterly, for new users and for production app releases)." 21 | echo "2. Beta (updated monthly, recommended for experienced users)." 22 | echo "3. Main (latest development branch, follows master channel)." 23 | echo "4. Master (latest development branch, for contributors)." 24 | echo 25 | 26 | echo "Channel? [1-4]: " 27 | read channel 28 | 29 | if [ "$channel" = '1' ] 30 | set -x channel "stable" 31 | else if [ "$channel" = '2' ] 32 | set -x channel "beta" 33 | else if [ "$channel" = '3' ] 34 | set -x channel "main" 35 | else if [ "$channel" = '4' ] 36 | set -x channel "master" 37 | else 38 | echo 39 | echo "Please select channel" 40 | exit 41 | end 42 | 43 | echo 44 | echo "installing Fluter $channel" 45 | echo 46 | 47 | # Select OS 48 | echo 49 | echo "Please chose your os:" 50 | echo "1. Arch linux based OS (Pacman)." 51 | echo "2. Debian 11 based OS or newer (APT)." 52 | echo "3. Ubuntu 20.04 LTS based OS or newer (APT)." 53 | echo 54 | 55 | # Read Input 56 | echo "Your OS? [1-3]: " 57 | read OS 58 | 59 | if [ "$OS" = '1' ] 60 | set -x os "pacman" 61 | else if [ "$OS" = '2' ] 62 | set -x os "apt" 63 | else if [ "$OS" = '3' ] 64 | set -x os "aptub" 65 | else 66 | echo 67 | echo "Please select your os (1, 2 or 3)" 68 | exit 69 | end 70 | 71 | # Android studio 72 | echo 73 | echo "Do you want Install with Android Studio?" 74 | echo 75 | 76 | echo "[Yes/yes/y/No/no/n]: " 77 | read astudio 78 | 79 | switch $astudio 80 | case "Yes" "yes" "y" 81 | echo 82 | echo "Installing with Android Studio" 83 | echo 84 | 85 | case "No" "no" "n" 86 | echo 87 | echo "Please chose Java version: " 88 | echo 89 | echo "1. Java 11 LTS" 90 | echo "2. Java 17 LTS" 91 | echo "3. Java 21 LTS" 92 | echo 93 | echo "[1-3]?: " 94 | read javaver 95 | 96 | if [ "$javaver" = '1' ] 97 | echo 98 | echo "selecting Java 11 LTS" 99 | echo 100 | else if [ "$javaver" = '2' ] 101 | echo 102 | echo "selecting Java 17 LTS" 103 | echo 104 | else if [ "$javaver" = '3' ] 105 | echo 106 | echo "selecting Java 21 LTS" 107 | echo 108 | else 109 | echo 110 | echo "Error, Please select correct java version (1, 2 or 3)." 111 | echo 112 | exit 113 | end 114 | 115 | case "*" 116 | echo 117 | echo "Error, Please repeat from the beginning and choose install with or without android." 118 | echo 119 | exit 120 | end 121 | 122 | 123 | # Install PKGS 124 | if test "$os" = "apt" -o "$os" = "aptub" 125 | sudo apt-get update 126 | sudo apt-get install git clang build-essential cmake ninja-build wget apt-transport-https libgtk-3-dev android-tools-adb which curl unzip -y 127 | 128 | switch $astudio 129 | case "Yes" "yes" "y" 130 | echo 131 | echo "Skip installing java, beacuse included with Android studio" 132 | echo 133 | 134 | case "No" "no" "n" 135 | sudo mkdir -p /etc/apt/keyrings 136 | wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc 137 | 138 | if [ "$os" = 'apt' ] 139 | echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list 140 | else if [ "$os" = 'aptub' ] 141 | echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^UBUNTU_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list 142 | end 143 | 144 | sudo apt-get update 145 | 146 | if [ "$javaver" = '1' ] 147 | sudo apt-get install temurin-11-jdk -y 148 | else if [ "$javaver" = '2' ] 149 | sudo apt-get install temurin-17-jdk -y 150 | else if [ "$javaver" = '3' ] 151 | sudo apt-get install temurin-21-jdk -y 152 | end 153 | end 154 | 155 | else if [ "$os" = 'pacman' ] 156 | sudo pacman -Syy --noconfirm git base-devel clang cmake ninja gtk3 android-tools which curl unzip 157 | 158 | switch $astudio 159 | case "Yes" "yes" "y" 160 | echo 161 | echo "Skip installing java, beacuse included with Android studio" 162 | echo 163 | 164 | case "No" "no" "n" 165 | if [ "$javaver" = '1' ] 166 | sudo pacman -Syy --noconfirm jdk11-openjdk 167 | else if [ "$javaver" = '2' ] 168 | sudo pacman -Syy --noconfirm jdk17-openjdk 169 | else if [ "$javaver" = '3' ] 170 | sudo pacman -Syy --noconfirm jdk21-openjdk 171 | end 172 | end 173 | end 174 | 175 | # Exporting PATH 176 | if grep -q "source \$HOME/Android/flutter.fish" "$HOME"/.config/fish/config.fish 177 | echo "Flutter is already on PATH" 178 | else 179 | echo 'source $HOME/Android/flutter.fish' >> "$HOME"/.config/fish/config.fish 180 | end 181 | 182 | # Create DIR 183 | if test -d "$ANDROID_SDK_ROOT" 184 | echo "The directory exists." 185 | else 186 | echo "Directory $ANDROID_HOME does not exist. Creating it now." 187 | mkdir -p $ANDROID_SDK_ROOT 188 | end 189 | 190 | cp -r flutter.fish $ANDROID_HOME/ 191 | cp -r flutterrc $ANDROID_HOME/ 192 | source $ANDROID_HOME/flutter.fish 193 | 194 | # Install Flutter and Android SDK 195 | ## clone Flutter 196 | git clone --depth 1 https://github.com/flutter/flutter.git -b $channel $ANDROID_HOME/flutter 197 | 198 | ## installing sdk 199 | switch $astudio 200 | case "Yes" "yes" "y" 201 | ./sdkmanager.sh $astudio 202 | 203 | case "No" "no" "n" 204 | ./sdkmanager.sh $javaver 205 | 206 | end 207 | 208 | sdkmanager "platform-tools" "build-tools;33.0.0" "platforms;android-33" 209 | sdkmanager --licenses 210 | flutter precache 211 | flutter doctor --android-licenses 212 | flutter doctor -v 213 | 214 | case "No" "no" "N" "n" 215 | echo 216 | echo "Cancel" 217 | exit 218 | 219 | case "*" 220 | echo 221 | echo "Error" 222 | exit 223 | end 224 | 225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | current_shell=$(basename "$SHELL") 4 | case $current_shell in 5 | bash | zsh) 6 | 7 | source flutterrc 8 | echo 9 | echo "This script will install package required by Flutter and will download required sdk to $ANDROID_HOME" 10 | echo 11 | 12 | # Read Input 13 | read -p "Continue? [Yes/yes/Y/y/No/no/N/n]: " confirm 14 | 15 | # Proccesing input 16 | case $confirm in 17 | Yes | yes | Y | y) 18 | # Select channel 19 | channel="stable" 20 | echo 21 | echo "Please slect flutter channel you want install:" 22 | echo "1. Stabel (default, updated quarterly, for new users and for production app releases)." 23 | echo "2. Beta (updated monthly, recommended for experienced users)." 24 | echo "3. Main (latest development branch, follows master channel)." 25 | echo "4. Master (latest development branch, for contributors)." 26 | echo 27 | 28 | # Read Input 29 | read -p "Channel? [1-4]: " channel 30 | 31 | if [ "$channel" == '1' ]; then 32 | channel="stable" 33 | elif [ "$channel" == '2' ]; then 34 | channel="beta" 35 | elif [ "$channel" == '3' ]; then 36 | channel="main" 37 | elif [ "$channel" == '4' ]; then 38 | channel="master" 39 | else 40 | echo 41 | echo "Please select channel" 42 | exit 43 | fi 44 | 45 | echo 46 | echo "installing Fluter $channel" 47 | echo 48 | 49 | # Select OS 50 | echo 51 | echo "Please chose your os:" 52 | echo "1. Arch linux based OS (Pacman)." 53 | echo "2. Debian 11 based OS or newer (APT)." 54 | echo "3. Ubuntu 20.04 LTS based OS or newer (APT)." 55 | echo 56 | 57 | # Read Input 58 | read -p "Your OS? [1-3]: " OS 59 | 60 | if [ "$OS" == '1' ]; then 61 | os="pacman" 62 | elif [ "$OS" == '2' ]; then 63 | os="apt" 64 | elif [ "$OS" == '3' ]; then 65 | os="aptub" 66 | else 67 | echo 68 | echo "Please select your os (1, 2 or 3)" 69 | exit 70 | fi 71 | 72 | # Android studio 73 | echo 74 | echo "Do you want Install with Android Studio?" 75 | echo 76 | 77 | # Read Input 78 | read -p "[Yes/yes/y/No/no/n]: " astudio 79 | 80 | case $astudio in 81 | Yes | yes | y) 82 | echo 83 | echo "Installing with Android Studio" 84 | echo 85 | ;; 86 | 87 | No | no | n) 88 | echo 89 | echo "Please chose Java version: " 90 | echo 91 | echo "1. Java 11 LTS" 92 | echo "2. Java 17 LTS" 93 | echo "3. Java 21 LTS" 94 | echo 95 | 96 | read -p "[1-3]?: " javaver 97 | 98 | if [ "$javaver" == '1' ]; then 99 | echo 100 | echo "selecting Java 11 LTS" 101 | echo 102 | elif [ "$javaver" == '2' ]; then 103 | echo 104 | echo "selecting Java 17 LTS" 105 | echo 106 | elif [ "$javaver" == '3' ]; then 107 | echo 108 | echo "selecting Java 21 LTS" 109 | echo 110 | else 111 | echo 112 | echo "Error, Please select correct java version (1, 2 or 3)." 113 | echo 114 | exit 115 | fi 116 | ;; 117 | 118 | *) 119 | echo 120 | echo "Error, Please repeat from the beginning and choose install with or without android." 121 | echo 122 | exit 123 | ;; 124 | esac 125 | 126 | # Intalling PKGS 127 | if [[ "$os" == "apt" || "$os" == "aptub" ]]; then 128 | sudo apt-get update 129 | sudo apt-get install git clang build-essential cmake ninja-build wget apt-transport-https libgtk-3-dev android-tools-adb which curl unzip -y 130 | case $astudio in 131 | Yes | yes | y) 132 | echo 133 | echo "Skip installing java, beacuse included with Android studio" 134 | echo 135 | ;; 136 | 137 | No | no | n) 138 | sudo mkdir -p /etc/apt/keyrings 139 | wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc 140 | 141 | if [ "$os" = 'apt' ]; then 142 | echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list 143 | elif [ "$os" = 'aptub' ]; then 144 | echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^UBUNTU_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list 145 | fi 146 | 147 | sudo apt-get update 148 | 149 | if [ "$javaver" = '1' ]; then 150 | sudo apt-get install temurin-11-jdk -y 151 | elif [ "$javaver" = '2' ]; then 152 | sudo apt-get install temurin-17-jdk -y 153 | elif [ "$javaver" = '3' ]; then 154 | sudo apt-get install temurin-21-jdk -y 155 | fi 156 | ;; 157 | esac 158 | 159 | elif [[ "$os" == 'pacman' ]]; then 160 | sudo pacman -Syy --noconfirm git base-devel clang cmake ninja gtk3 android-tools which curl unzip 161 | case $astudio in 162 | Yes | yes | y) 163 | echo 164 | echo "Skip installing java, beacuse included with Android studio" 165 | echo 166 | ;; 167 | 168 | No | no | n) 169 | if [ "$javaver" = '1' ]; then 170 | sudo pacman -Syy --noconfirm jdk11-openjdk 171 | elif [ "$javaver" = '2' ]; then 172 | sudo pacman -Syy --noconfirm jdk17-openjdk 173 | elif [ "$javaver" = '3' ]; then 174 | sudo pacman -Syy --noconfirm jdk21-openjdk 175 | fi 176 | ;; 177 | esac 178 | fi 179 | 180 | 181 | # Exporting PATH 182 | flutter_path="source \$HOME/Android/flutterrc" 183 | if [[ "$current_shell" == 'zsh' ]]; then 184 | if ! [ -f "$HOME"/.zshrc ]; then 185 | touch "$HOME"/.zshrc 186 | echo 'source $HOME/Android/flutterrc' >> "$HOME"/.zshrc 187 | elif grep -q "$flutter_path" "$HOME"/.zshrc; then 188 | echo "Flutter is already on PATH" 189 | else 190 | echo 'source $HOME/Android/flutterrc' >> "$HOME"/.zshrc 191 | fi 192 | 193 | elif [[ "$current_shell" == 'bash' ]]; then 194 | if ! [ -f "$HOME"/.bashrc ]; then 195 | touch "$HOME"/.bashrc 196 | echo 'source $HOME/Android/flutterrc' >> "$HOME"/.bashrc 197 | elif grep -q "$flutter_path" "$HOME"/.bashrc; then 198 | echo "Flutter is already on PATH" 199 | else 200 | echo 'source $HOME/Android/flutterrc' >> "$HOME"/.bashrc 201 | fi 202 | fi 203 | 204 | # Create DIR 205 | if ! [ -d "$ANDROID_SDK_ROOT" ]; then 206 | echo "Directory $ANDROID_HOME does not exist. Creating it now." 207 | mkdir -p $ANDROID_SDK_ROOT 208 | fi 209 | 210 | cp -r flutterrc $ANDROID_HOME/ 211 | cp -r flutter.fish $ANDROID_HOME/ 212 | source $ANDROID_HOME/flutterrc 213 | 214 | # Install Flutter and Android SDK 215 | ## clone Flutter 216 | git clone --depth 1 https://github.com/flutter/flutter.git -b $channel $ANDROID_HOME/flutter 217 | 218 | ## installing sdk 219 | case $astudio in 220 | Yes | yes | y) 221 | ./sdkmanager.sh $astudio 222 | ;; 223 | 224 | No | no | n) 225 | ./sdkmanager.sh $javaver 226 | ;; 227 | esac 228 | 229 | 230 | sdkmanager "platform-tools" "build-tools;33.0.0" "platforms;android-33" 231 | sdkmanager --licenses 232 | flutter precache 233 | flutter doctor --android-licenses 234 | flutter doctor -v 235 | ;; 236 | 237 | No | no | N | n) 238 | echo "Cancel" 239 | exit 240 | ;; 241 | 242 | *) 243 | echo "Error" 244 | exit 245 | ;; 246 | 247 | esac 248 | ;; 249 | 250 | fish) 251 | ./install.fish 252 | ;; 253 | 254 | *) 255 | echo 256 | echo "only support bash/zsh/fish shell (your shell is: $current_shell)" 257 | echo 258 | echo "exit.." 259 | exit 260 | ;; 261 | 262 | esac 263 | 264 | -------------------------------------------------------------------------------- /sdkmanager.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Define the URL, file name, and expected checksum 4 | URL="https://example.com/path/to/your/file" 5 | FILENAME="yourfile.ext" 6 | EXPECTED_CHECKSUM="expected_checksum_here" 7 | ANDROID_SDK_ROOT="$HOME/Android/sdk" 8 | 9 | # Extract FILE 10 | extract_file() { 11 | if [ "$FILE" == "sdkmanager" ]; then 12 | unzip $FILENAME 13 | elif [ "$FILE" == "android-studio" ]; then 14 | tar -xvf $FILENAME 15 | fi 16 | } 17 | 18 | # Function to calculate checksum 19 | calculate_checksum() { 20 | local file="$1" 21 | echo $(sha256sum "$file" | awk '{print $1}') 22 | } 23 | 24 | redownload () { 25 | echo 26 | echo "Downloaded file checksum mismatch. Redownload file?." 27 | echo 28 | 29 | # Read Input 30 | read -p "Redownload? [Yes/yes/y/No/no/n]: " redown 31 | 32 | case $redown in 33 | Yes | yes | y) 34 | processfile 35 | ;; 36 | 37 | *) 38 | echo 39 | echo "Please start again from beginning" 40 | echo 41 | exit 42 | ;; 43 | esac 44 | } 45 | 46 | processfile () { 47 | # Check if the file exists 48 | if [ -e "$FILENAME" ]; then 49 | # Calculate the current checksum of the file 50 | CURRENT_CHECKSUM=$(calculate_checksum "$FILENAME") 51 | 52 | # Compare the current checksum with the expected checksum 53 | if [ "$CURRENT_CHECKSUM" == "$EXPECTED_CHECKSUM" ]; then 54 | echo "Checksum matched. File is valid." 55 | extract_file 56 | else 57 | echo "Checksum mismatch. Downloading the file again..." 58 | # Download the file using curl 59 | curl -o "$FILENAME" "$URL" 60 | 61 | # Verify the newly downloaded file's checksum 62 | NEW_CHECKSUM=$(calculate_checksum "$FILENAME") 63 | if [ "$NEW_CHECKSUM" == "$EXPECTED_CHECKSUM" ]; then 64 | echo "Downloaded file checksum verified. File is valid." 65 | extract_file 66 | else 67 | redownload 68 | fi 69 | fi 70 | else 71 | echo "File not found. Downloading the file..." 72 | # Download the file using curl 73 | curl -o "$FILENAME" "$URL" 74 | 75 | # Verify the downloaded file's checksum 76 | NEW_CHECKSUM=$(calculate_checksum "$FILENAME") 77 | if [ "$NEW_CHECKSUM" == "$EXPECTED_CHECKSUM" ]; then 78 | echo "Downloaded file checksum verified. File is valid." 79 | extract_file 80 | else 81 | redownload 82 | fi 83 | fi 84 | } 85 | 86 | case $1 in 87 | Yes | yes | y) 88 | # Define the URL, file name, and expected checksum 89 | FILE="android-studio" 90 | VER="2024.3.2.15" 91 | FILENAME="android-studio-"$VER"-linux.tar.gz" 92 | URL="https://r3---sn-npoe7ndl.gvt1.com/edgedl/android/studio/ide-zips/"$VER"/"$FILENAME"" 93 | EXPECTED_CHECKSUM="2fcb3c975fd0e002441af7734cb2eef6c459964372443310bcaf26a195ce7881" 94 | 95 | if [ -d android-studio ]; then 96 | rm -rf android-studio 97 | fi 98 | 99 | processfile 100 | 101 | cp android-studio.desktop /usr/share/applications/ 102 | if [ -d /opt/android-studio ]; then 103 | sudo rm -rf /opt/android-studio 104 | fi 105 | 106 | sudo mv android-studio /opt/ 107 | flutter config --android-studio-dir=/opt/android-studio 108 | ;; 109 | esac 110 | 111 | case $1 in 112 | Yes | yes | y | 2 | 3) 113 | # Define the URL, file name, and expected checksum 114 | FILE="sdkmanager" 115 | FILENAME="commandlinetools-linux-13114758_latest.zip" 116 | URL="https://dl.google.com/android/repository/"$FILENAME"" 117 | EXPECTED_CHECKSUM="7ec965280a073311c339e571cd5de778b9975026cfcbe79f2b1cdcb1e15317ee" 118 | 119 | if [ -d cmdline-tools ]; then 120 | rm -rf cmdline-tools 121 | fi 122 | 123 | processfile 124 | 125 | if ! [ -d "$ANDROID_SDK_ROOT"/cmdline-tools/latest ]; then 126 | mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/latest 127 | else 128 | rm -rf $ANDROID_SDK_ROOT/cmdline-tools/latest/* 129 | fi 130 | 131 | mv cmdline-tools/* $ANDROID_SDK_ROOT/cmdline-tools/latest/ 132 | rm -rf cmdline-tools 133 | ;; 134 | 135 | 1) 136 | # Define the URL, file name, and expected checksum 137 | FILE="sdkmanager" 138 | FILENAME="commandlinetools-linux-9477386_latest.zip" 139 | URL="https://dl.google.com/android/repository/"$FILENAME"" 140 | EXPECTED_CHECKSUM="bd1aa17c7ef10066949c88dc6c9c8d536be27f992a1f3b5a584f9bd2ba5646a0" 141 | 142 | if [ -d cmdline-tools ]; then 143 | rm -rf cmdline-tools 144 | fi 145 | 146 | processfile 147 | 148 | if ! [ -d "$ANDROID_SDK_ROOT"/cmdline-tools/latest ]; then 149 | mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/latest 150 | else 151 | rm -rf $ANDROID_SDK_ROOT/cmdline-tools/latest/* 152 | fi 153 | 154 | mv cmdline-tools/* $ANDROID_SDK_ROOT/cmdline-tools/latest/ 155 | rm -rf cmdline-tools 156 | ;; 157 | esac --------------------------------------------------------------------------------