Skip to content

Commit

Permalink
Initial commit of reset-android-studio-mac.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
chimbori authored Aug 21, 2021
1 parent dad0a30 commit 954568b
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions reset-android-studio-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Manas Tungare <[email protected]>

# If any one command fails, immediately exit.
# Treat unset variables as an error, and immediately exit.
set -eu

export LANG=en_US.UTF-8
export TERM=xterm-256color
export CLICOLOR=yes
RED="\033[00;31m"
YELLOW="\033[01;33m"
NORMAL="\033[00m"

trap "echo -e \"\n${RED}Cancelling all operations.${NORMAL}\"; exit;" INT TERM

function message() {
echo -e "${YELLOW}$1${NORMAL}"
}

echo -e "⚠️ ${YELLOW}This will completely delete all Gradle & Android Studio caches & config, and will require you to re-import the project from scratch.${NORMAL}"
echo -n "Press Enter to confirm, or Ctrl+C to cancel… "
read ignorePressedKey
echo ""

# Check if this script is being run from the correct location.
if [ ! -f "./gradlew" ]; then
echo -e "${RED}“gradlew” not found at “$(pwd)${NORMAL}"
echo "Consider running this script from the root of an Android Studio project."
echo -n "Press Enter to continue, or Ctrl+C to abort… "
read ignorePressedKey
echo ""
fi

# Script begins!
message "Killing ADB…"
adb kill-server
killall adb

message "Cleaning current project, including Gradle & Android Studio caches & config…"
pwd
./gradlew clean
./gradlew cleanBuildCache
./gradlew --stop
find . -iname ".idea" -print -exec rm -Rfv "{}" \;
find . -iname ".gradle" -print -exec rm -Rfv "{}" \;
find . -iname "build" -print -exec rm -Rfv "{}" \;
find . -iname "*.iml" -print -exec rm -Rfv "{}" \;

message "Deleting global state, including Gradle & Android Studio caches & config…"
rm -v ~/Library/Preferences/com.google.android.studio.plist
rm -Rfv ~/Library/Preferences/AndroidStudio*
rm -Rfv ~/Library/Application\ Support/AndroidStudio*
rm -Rfv ~/Library/Logs/AndroidStudio*
rm -Rfv ~/Library/Caches/AndroidStudio*

0 comments on commit 954568b

Please sign in to comment.