Issue
I am trying to execute
cordova run android --verbose
and I get
spawn EACCES
as an error.
So, I searched online and ran
cordova run android --verbose
and identified the error to be:
Running command: /snap/android-studio/76/android-studio/gradle/gradle-5.1.1/bin/gradle -p /home/extensify/Desktop/Code/cordova/platforms/android wrapper -b /home/extensify/Desktop/Code/cordova/platforms/android/wrapper.gradle
spawn EACCES
Error: spawn EACCES
at _errnoException (util.js:1022:11)
at ChildProcess.spawn (internal/child_process.js:323:11)
at Object.exports.spawn (child_process.js:502:9)
at Function.spawn (/home/extensify/Desktop/Code/cordova/node_modules/cross-spawn/index.js:12:24)
at exports.spawn (/home/extensify/Desktop/Code/cordova/node_modules/cordova-common/src/superspawn.js:90:28)
at ProjectBuilder.runGradleWrapper (/home/extensify/Desktop/Code/cordova/platforms/android/cordova/lib/builders/ProjectBuilder.js:70:20)
at /home/extensify/Desktop/Code/cordova/platforms/android/cordova/lib/builders/ProjectBuilder.js:209:29
at _fulfilled (/home/extensify/Desktop/Code/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (/home/extensify/Desktop/Code/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (/home/extensify/Desktop/Code/cordova/node_modules/q/q.js:816:13)
Which I read can be fixable by changing permissions for the file /snap/android-studio/76/android-studio/gradle/gradle-5.1.1/bin/gradle
To fix this I tried running
sudo chmod +x /snap/android-studio/76/android-studio/gradle/gradle-5.1.1/bin/gradle
and kept getting
chmod: changing permissions of '/snap/android-studio/76/android-studio/gradle/gradle-5.1.1/bin/gradle': Read-only file system
Which I read can be fixed by remounting my hard drive, which again I tried using several commands, but could not be fixed.
What can I try next?
Solution
This answer is for Ubuntu 18.04
I had this same problem and here's how I fixed them:
- Remove Android Studio if you installed it using snap.
- Download Android Studio from their website
- Extract to
/usr/local/
for your user profile, or/opt/
for shared users - If you are using a 64-bit machine, run this command to install some required 32-bit packages:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
- Install KVM, add yourself to group
kvm
- Open a terminal, navigate to the
android-studio/bin/
directory, and execute./studio.sh
- Run through the installation and make sure you install API Level 28 (Android 9.0 Pie) in SDK Platform
- Add the following directories to
$PATH
:/opt/android-studio/gradle/gradle-{version}/bin
or/usr/local/android-studio/gradle/gradle-{version}/bin
/opt/android-studio/jre/bin
or/usr/local/android-studio/jre/bin
/home/{name}/Android/Sdk/platform-tools
/home/{name}/Android/Sdk/tools/bin
/home/{name}/Android/Sdk/emulator/bin
- Create a virtual device using Android Studio
- List virtual devices using
android list avd
- Start a virtual device using
emulator -avd {deviceName}
- Run
cordova run android
, it should work
Recommended:
- Run Android Studio, go to
Tools > Create Desktop Entry...
so that you can launch Android Studio easily
Answered By - Akaanksh Raj Answer Checked By - David Marino (WPSolving Volunteer)