ionic-cli: Ionic build android, Error: spawn EACCES

What version of the CLI are you using? Output of ionic --version

2.2.3

Short description of the problem:

I downloaded a fresh instalation of ionic and cordova, then I created a new project, then I added the android platform and tried to build. The build fails with Error: spawn EACCES.

What behavior are you expecting?

The projects should build succesfully.

Steps to reproduce:

  1. sudo npm install -g cordova ionic
  2. ionic start myApp tabs
  3. cd myApp
  4. ionic platform add android@6.2.2 //6.1.x has a bug
  5. ionic build android

Post the output of ionic info below please Your system information:

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.6
ios-deploy version: 1.8.5 
ios-sim version: 5.0.13 
OS: OS X El Capitan
Node Version: v6.10.1
Xcode version: Xcode 7.3.1 Build version 7D1014

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 33 (3 by maintainers)

Most upvoted comments

@alexharvey assuming you’re on mac (or linux):

chmod +x /Applications/Android Studio 2.4 Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle

WOW it’s working. sudo cordova run android --verbose

change permissions of that file like this sudo chmod 755 “/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle”

Running ionic build android --verbose gives the following output:

Running command: "/Applications/Android Studio 2.4 
Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle" -p 
/Users/rlopez/myApp/platforms/android wrapper -b 
/Users/rlopez/myApp/platforms/android/wrapper.gradle

Error: spawn EACCES
    at exports._errnoException (util.js:1018:11)
    at ChildProcess.spawn (internal/child_process.js:319:11)
    at Object.exports.spawn (child_process.js:378:9)
    at exports.spawn(/Users/rlopez/myApp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:134:31)
    at GradleBuilder.runGradleWrapper(/Users/rlopez/myApp/platforms/android/cordova/lib/builders/GradleBuilder.js:78:14)
    at /Users/rlopez/myApp/platforms/android/cordova/lib/builders/GradleBuilder.js:178:21
    at _fulfilled (/Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:854:54)
    at self.promiseDispatch.done (/Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:883:30)
    at Promise.promise.promiseDispatch (/Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:816:13)
    at /Users/rlopez/myApp/platforms/android/cordova/node_modules/q/q.js:570:49

Changing the permissions of /Applications/Android Studio 2.4 Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle solves the problem.

@djonmayer: i figured it out:

sudo cordova run android --verbose

look for the error message:

Running command: "/Applications/Android Studio 3.0 Preview.app/Contents/gradle/gradle-4.0-milestone-1/bin/gradle"

change permissions of that file like this sudo chmod 755 /Applications/Android\ Studio\ 3.0\ Preview.app/Contents/gradle/gradle-4.0-milestone-1/bin/gradle

look at the slashes before the spaces. this is likely what you are missing

@AwesomeJ0sh thanks, i figured it out i made the gradlew file executable chmod +x /home/davinci/Tutorials/ionic/favourite-app/platforms/android/gradlew

Thank you it solved my problem as well

sudo chmod 755 “/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle”

works fines for me. the problem is the android studio app upgrade.

I had similar error on Mac when I updated my Android Studio to version 3.x. I found the following command to fix it: sudo chmod 755 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle

@timofeysie hey man. I know what you mean. I was frustrated for a while too.

It seems you are experiencing two different errors.

the first error has to do with this file: /Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle change permissions to this gradle file like this sudo chmod 755 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle

However. it doesn’t seem like you are at this point because your second error has to do with the installation android studio. You have to complete it by opening it and accepting their license? I don’t know first hand I have never experienced it.

aside: I also program on a mac. Include sudo with most commands if they fail on permission the first time.

sorry sudo chmod 755 /home/davinci/Tutorials/ionic/favourite-app/platforms/android/gradlew\ cdvBuildDebug