Created
March 7, 2025 22:26
-
-
Save mofakhamr/0e5471b771205d695e196400b4767331 to your computer and use it in GitHub Desktop.
Parametized version of Android sdk for wsl2
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
# Set your preferred android version | |
ANDROID_VERSION=34 | |
# Down on this page, you can download the latest sdk, grab the url from | |
# the network console after you've accepted the T&Cs | |
# https://developer.android.com/studio#command-tools | |
SDK_TOOLS=commandlinetools-linux-11076708_latest.zip | |
# Choose a java version, I prefer openjdk | |
JAVA_VERSION=21 | |
echo "### Download and setup SDK ###" | |
cd $HOME | |
sudo apt-get install -y unzip | |
wget https://dl.google.com/android/repository/${SDK_TOOLS} | |
unzip ${SDK_TOOLS} -d android_sdk | |
rm ${SDK_TOOLS} | |
cd android_sdk/cmdline-tools | |
mkdir latest | |
mv bin/ latest/bin/ | |
mv lib/ latest/lib/ | |
mv NOTICE.txt latest/NOTICE.txt | |
mv source.properties latest/source.properties | |
# (Optional) To install a previous version of the command-line tools, run the following command: | |
# Substitute version with the version you want to install, for example 5.0. | |
# android_sdk/cmdline-tools/latest/bin/sdkmanager --install "cmdline-tools;version" | |
echo "### Install Java ###" | |
sudo apt-get install -y lib32z1 openjdk-${JAVA_VERSION}-jdk | |
export JAVA_HOME=/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64 | |
export PATH=$PATH:$JAVA_HOME/bin | |
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc | |
echo "### Install build tools ###" | |
cd ~/android_sdk/cmdline-tools/latest/bin/ | |
./sdkmanager "platform-tools" "platforms;android-${ANDROID_VERSION}" "build-tools;34.0.0" | |
echo "### Setup paths ###" | |
printf "\n\nexport ANDROID_HOME=\$HOME/android_sdk\nexport PATH=\$PATH:\$ANDROID_HOME/tools\nexport PATH=\$PATH:\$ANDROID_HOME/platform-tools" >> ~/.bashrc | |
source ~/.bashrc | |
# android belonged to $ANDROID_HOME/tools but is no longer included in the latest android studio build | |
# You can still install the SDK tools using the SDK manager in the Android studio. | |
# https://stackoverflow.com/a/60466658 | |
# android update sdk --no-ui --use-sdk-wrapper | |
echo "### Install latest gradle ###" | |
sudo add-apt-repository ppa:cwchien/gradle | |
sudo apt-get update | |
sudo apt-get install gradle | |
gradle -v | |
# If you already have gradle installed, you can update it by doing: | |
#sudo apt upgrade gradle | |
echo "### Start ADB ###" | |
adb start-server | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment