I have a ionic angular application.
When I run ‘ionic capacitor build android’ from WSL
I get the following errors:
[INFO] Ready for use in your Native IDE!
To continue, build your project using Android Studio!
> capacitor open android
[capacitor] [error] Unable to launch Android Studio. Is it installed?
[capacitor] Attempted to open Android Studio at: /usr/local/android-studio/bin/studio.sh
[capacitor] You can configure this with the CAPACITOR_ANDROID_STUDIO_PATH environment variable.
I have android studio installed and additionally have set the system env variable for CAPACITOR_ANDROID_STUDIO_PATH with the path to its windows location.
I have also tried the suggested fixes on here CAPACITOR_ANDROID_STUDIO_PATH environment variable in Ionic 5
which also doesn’t work
Wondering if anyone can help
Thanks
2
Answers
Had the exact same error. My Android Studio is at a different location as I use the snap.
So first figure out where studio is:
And then add the variable to your .bashrc (or e.g. .zshrc):
Restart your terminal and it should work.
Here’s what I did:
Step 1: Identity the location of your studio.sh
There could be a lot of location where it’s location. For me, I installed Android Studio from Ubuntu Software where the installed location is in
/snap/android-studio/current/android-studio/bin/studio.sh
Step 2: Add to Environment variable
vim ~/.bashrc
Then append this line with your location of studio.sh like this:
export CAPACITOR_ANDROID_STUDIO_PATH="/snap/android-studio/current/android-studio/bin/studio.sh"
Step 3: Restart terminal or type in
$ source ~/.bashrc
I hope this helps.