When I run the ionic capacitor run android
command, to launch my application in Android Studio, I get the error saying:
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" }
but I configured the path my capacitor.config.json but the error persists.
Here's my capacitor.config.json file
First, run whereis android-studio
in your terminal. This command will return the path of your android studio.
Mine is /snap/android-studio/current/android-studio/bin/studio.sh
. I installed android-studio from the ubuntu software store. Maybe you installed it through a different source and in a different location.
Then add "linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh"
in capacitor.config.json which is located in the root of your project.
Replace /snap/android-studio/current/android-studio/bin/studio.sh
by your path. which is returned to you by whereis android-studio
in my case, android studio location was "/opt/android-studio/bin/studio.sh"
{
...
"linuxAndroidStudioPath": "/opt/android-studio/bin/studio.sh"
}
"linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh"
is the path.
Add sudo when running the project sudo npx cap open android
I use JetBrains Toolbox and macOS
to open the capacitor project with Android Studio with npx cap open android
I had to export the Android Studio path as follow:
export CAPACITOR_ANDROID_STUDIO_PATH="/Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/Android Studio.app"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With