Ionic build android, Error: spawn EACCES


#1

If I follow this steps to create a new app:

Rubens-MacBook-Pro:~ rlopez$ npm install -g cordova ionic
Rubens-MacBook-Pro:~ rlopez$ ionic start myApp tabs
Rubens-MacBook-Pro:~ rlopez$ cd myApp
Rubens-MacBook-Pro:myApp rlopez$  ionic platform add android@6.2.2 //6.1.x has a bug
Rubens-MacBook-Pro:myApp rlopez$  ionic build android

I get this output:

> ionic-hello-world@ ionic:build /Users/rlopez/Proyectos/sfp-concursaPy
> ionic-app-scripts build

[15:13:28]  ionic-app-scripts 1.1.4 
[15:13:28]  build dev started ... 
[15:13:28]  clean started ... 
[15:13:28]  clean finished in 3 ms 
[15:13:28]  copy started ... 
[15:13:28]  transpile started ... 
[15:13:31]  transpile finished in 2.96 s 
[15:13:31]  preprocess started ... 
[15:13:31]  preprocess finished in less than 1 ms 
[15:13:31]  webpack started ... 
[15:13:31]  copy finished in 3.17 s 
[15:13:41]  webpack finished in 9.26 s 
[15:13:41]  sass started ... 
[15:13:41]  sass finished in 897 ms 
[15:13:41]  postprocess started ... 
[15:13:41]  postprocess finished in 1 ms 
[15:13:41]  lint started ... 
[15:13:41]  build dev finished in 13.15 s 
[15:13:43]  lint finished in 2.04 s 
ANDROID_HOME=/Users/rlopez/Library/Android/sdk

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home

Error: spawn EACCES

Running ionic info gives the following:


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

What am I doign wrong? Is this a bug in Ionic?

[Edit]

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.


#2

EACCES is a permission failure, so it would help to know what it was trying to access when the error happened. Is there anything like that in the console output?


#3

That’s the problem. There’s nothing else in the console. Every other question I found on the Internet has at least some other output or stacktrace but not in this case.


#4

i’m getting the same thing. were you able to fix this?


#5

Yes I was. I made an edit to the post detailing how I fix it. Changing the permissions of /Applications/Android Studio 2.4 Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle solved the problem for me.


#6

@rubenlop88 what was the permissions you’ve changed ( from -> to ) ?


#7

I am getting a similar error with ionic 3

sudo ionic cordova build android --verbose

produces

[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/MYUSERNAME/Downloads/asa/asa', local: true, binPath: 
        '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: 
        '/Users/MYUSERNAME/Downloads/asa/asa/node_modules/ionic/dist/index.js' }
[DEBUG] New daemon pid: 700
Running app-scripts build: etc etc.

✔ cordova prepare - done!

✖ cordova build android - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):

        
        ANDROID_HOME=/Users/MYUSERNAME/Library/Android/sdk
        JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
        Error: spawn EACCES

any help would be appreciated.


#8

Hey I figured this error out. Read here
Github fix for Error: spawn EACCES


#9

Try changing the permission:

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

Then run ionic build android again.


#10

ANDROID_HOME=/Volumes/TimeMachine/Android_SDK
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
Error: spawn EACCES

[ERROR] An error occurred while running cordova run android (exit code 1).

same error
:frowning:


#11

See here:


#12

can you say it clearly


#13

ANDROID_HOME=/Users/bvmac001/Library/Android/sdk/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
Subproject Path: CordovaLib
(node:1346) UnhandledPromiseRejectionWarning: 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 Object.exports.spawn (/Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:134:31)
at GradleBuilder.build (/Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/lib/builders/GradleBuilder.js:225:23)
at /Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/lib/build.js:151:24
at _fulfilled (/Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (/Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (/Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/node_modules/q/q.js:816:13)
at /Users/bvmac001/Documents/Vignesh/IonicProjects/TheCrowdtest/platforms/android/cordova/node_modules/q/q.js:624:44
(node:1346) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1346) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

help me out from this , Thanks in advance