I was using Cordova to run my Hybrid app on my Android device, and I got this error twice during the unsuccessful build ...
Error: spawn EACCES
@Krunel Vaghela's answer above helped me somewhat ...
This is Permission Error While Building App
You Need to Give Permission Gradle
sudo chmod -R 777 /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/gradle
But I kept having this error:
"chmod: -r: no such file or directory"
I was using this command:
[Sandis-Macbook-Pro:Users sandi$ sudo chmod -R 777 /Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle
Note that my Android app is named "Android Studio.app" (with a space in the name). Solution is to simply wrap the path in quotes like so:
[Sandis-Macbook-Pro:Users sandi$ sudo chmod -R 777 "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle"
NOTE: In order to find out which folder was having the permissions problem, I had to use this command:
sudo build -verbose
Which yielded the path to the permissions problem folder like this:
ANDROID_HOME=/Users/sandi/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
Running command: "/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle" -p /Users/sandi/Desktop/CORDOVA_NOV16/HHUB_NOV17/hhub_CURRENT/platforms/android wrapper -b /Users/sandi/Desktop/CORDOVA_NOV16/HHUB_NOV17/hhub_CURRENT/platforms/android/wrapper.gradle
Error: spawn EACCES
So take the path after "Running command:" - put that, inside quotes, after the ...
chmod -r 777
And that's what saved my day.