Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Ionic app on android-studio with capacitor on Ubuntu?

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.

enter image description here

Here's my capacitor.config.json file

enter image description here

like image 870
speedhacker Avatar asked Apr 02 '19 18:04

speedhacker


4 Answers

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

like image 96
Sajid Javed Avatar answered Oct 26 '22 06:10

Sajid Javed


in my case, android studio location was "/opt/android-studio/bin/studio.sh"

{
  ...
  "linuxAndroidStudioPath": "/opt/android-studio/bin/studio.sh"
}
like image 29
Omar Elsehrawy Avatar answered Oct 26 '22 04:10

Omar Elsehrawy


"linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh" is the path.

Add sudo when running the project sudo npx cap open android

like image 3
Okan Beydanol Avatar answered Oct 26 '22 04:10

Okan Beydanol


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" 
like image 1
RenRen Avatar answered Oct 26 '22 04:10

RenRen