How to use Android Studio with WSL (bash) as your shell Terminal?
Solution 1
Yes, it is possible. I'm doing it right now. I have an Ubuntu app as WSL and figured out that it's accessible at C:\Windows\System32\bash.exe
So, open Android Studio and navigate to File -> Settings -> Tools -> Terminal. There fill Shell paht
with C:\Windows\System32\bash.exe
and voilà!
Now, when you open a new terminal it will use the WSL you have installed in your machine.
I'm using Android Studio 4.0.1.
Solution 2
I'm setting this up right now and hit your question from Google looking for advice. So with that caveat, let me explain what I did to get it running and if you have follow up questions we may need to experiment together to find the answers.
First, I installed VcXserv: https://sourceforge.net/projects/vcxsrv/. This X Server for windows allows you to run graphical linux applications in WSL. You'll just need to export the display variable in your ~/.bashrc since that isn't done normally in WSL:
$ echo "export DISPLAY=:0" >> ~/.bashrc
Then you have to run XLaunch from the start menu. It takes you through the config dialogs (just choose the defaults) and it puts an icon in the notification area you can check to make sure it's running.
Then, you want to download the Linux version of Android Studio 3.1. Extract it into the WSL filesystem somewhere (I used ~/apps). Then from your bash shell you can run android-studio/bin/studio.sh
and the window will appear and begin the unboxing dialogs.
This is as far as I've gotten, right now it's downloading the SDK. I still am not sure how adb over usb is going to work or tested the emulator. I'll update this if I learn more.
Update unfortunately, VcXserv is crashing when the main Android Studio window launches. I'm going to file a bug report on it and try some other X servers if I have time later.
Jakub Gruber
Updated on June 25, 2022Comments
-
Jakub Gruber almost 2 years
Is it possible to use Android Studio and configure Windows Subsystem for Linux as a Terminal? I really don't like to work with Windows
cmd.exe
, but when I try to switch tobash.exe
, which seems to work, it cannot build the project because there are missing e.g.Android/sdk/build-tools/27.0.3/aidl'
.This file is there, but it is with
.exe
suffix as it was downloaded for Windows. Any workaround to use *unix like bash for Terminal in Android Studio while being on Windows 10? -
WillDeStijl almost 6 yearsHow's it going on this? I'm very interested in the same.
-
Segfault almost 6 yearsI've tried a few other windows X servers but haven't found anything better than VcXsrv. It works ok for linux Visual Studio Code and GitKraken, so I think any Electron based app should be fine, but still crashes on Android Studio. I've moved on for now.
-
Nic over 5 yearsFor anyone (like me) looking at this to get Flutter working, you don't need to run Android Studio. This should be sufficient. I haven't tested it yet, but I'm about to, and I'll report back when I do.
-
noname almost 5 yearsIs still someone who looking for help with it? If yes what I did is I go to: File >Settings then type in search Terminal and in shell path I added path to wsl.exe which in my case was C:\Windows\System32\wsl.exe I hope that help.
-
Ride Sun over 4 yearsAny news on this topic? I spend a few days to investigate but I never got XFCE4 running in a stable way
-
Fco P. about 3 yearsSo simple and so useful. For me at least this is a game changer, thanks!
-
Val Martinez about 3 yearsIn my case, using Debian over w10, pretty much the same; but the dir was C:\Program Files\WindowsApps\TheDebianProject.DebianGNULinux_1.3.0.0_x64__76v4gfsz19hv4\debian.exe