sudo apt update
sudo apt install openjdk-8-jdk-headless
wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
mkdir -p Android/cmdline-tools
unzip commandlinetools-linux-8512546_latest.zip -d Android/cmdline-tools
mv Android/cmdline-tools/cmdline-tools Android/cmdline-tools/latest
export ANDROID_HOME=$HOME/Android
# Make sure emulator path comes before tools. Had trouble on Ubuntu with emulator from /tools being loaded
# instead of the one from /emulator
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
# don't need this anymore
# sdkmanager --sdk_root=${ANDROID_HOME} "tools"
sdkmanager --update
sdkmanager --list
# find current version
sdkmanager --list | grep build-tools
# change the version below with whatever version is downloaded
sdkmanager "build-tools;30.0.3" "platform-tools" "platforms;android-30" "tools"
sdkmanager --licenses
sudo apt install gradle
Please find the latest version of Android SDK at: https://developer.android.com/studio/#downloads (scroll to the bottom of the page under the section "Command Line Tools only"
Used a combinaton of these gists:
- https://gist.github.com/fedme/fd42caec2e5a7e93e12943376373b7d0
- https://gist.github.com/jjvillavicencio/18feb09f0e93e017a861678bc638dcb0
Background on the update to command line tools from android sdk: https://stackoverflow.com/a/61176718
https://stackoverflow.com/questions/65262340/cmdline-tools-could-not-determine-sdk-root
I installed the following in my WSL2 ubuntu environment
I tried with the openjdk 8 and 11 both
8 issue
11 issue
I tried different methods of installing jdk from other sources but still the issue persists.
UPDATE #1
JDK 17 worked out fine
everything works just fine but the issue is when i try to run a react native project from wsl with all this setup it does open up the expo go application on my phone for debuging but it doesn't run the application that is something which i am figuring right now.
And btw i used adb tcp server on port 5555 on my windows machine and then adb connected to the phone's ip address with the port 5555 and it worked just fine, connection was established
UPDATE #2
As long as it works I'm fine with it🥴
I tried every possible way but still I could not configure the wsl appropriately for android development.
So I followed a different approach
There you have it 8 hours of pain finally paid off I hope it helps other lost souls.💀