'linuxAndroidStudioPath' error when attempting 'npx cap open android' despite value correctly defined

Environment: wsl2 - ubuntu-18.04, nodejs 12.16.1, ionic-cli 6.4.1, capacitor-cli 6.14.4

I have added the correct path to android studio in capacitor.config.json but npx cap open android still gives the following error:

[error] Unable to launch Android Studio. You must configure "linuxAndroidStudioPath" in your capacitor.config.json to point to the location of studio.sh, using JavaScript-escaped paths:
Example:
{
  "linuxAndroidStudioPath": "/usr/local/android-studio/bin/studio.sh"
}

I have a functioning android studio installation, with all the proper paths set in .bashrc to the sdk and studio.sh. I am able to open the project manually without errors but the npx command does not work.

Thanks in advance!

After some more digging and some less than savory debug logging, I discovered the issue wasn’t with the definition at all. The definition was correct, the file existed, but for some reason the opn command is erroring out with exit code 1. I don’t see any permissions issues or anything so I’m not sure exactly what is up.

I’ve filed a bug report about the misleading error message here but if anyone knows why cap open android would return exit code 1, when running the equivalent open code on the command line myself gives a successful launch, I would love to hear ideas!

Hi,
I had the same issue. It was because i had install Android studio with snap.
I resolved it by adding this line in the capacitor.config.json:

“linuxAndroidStudioPath”: “/snap/android-studio/98/android-studio/bin/studio.sh”

Working with Android studio 4.1.1 - Ubuntu 20.10 - Ionic 6.12