Ionic build android, Error: spawn EACCES

2020-05-14 14:18发布

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

16条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-05-14 14:21

Only for OSX --- Go to Applications Folder from finder and Simply rename Android Studio App Package name by removing space between.

Before : Android Studio After: AndroidStudio

There is no issue of permissions by default just the space was the problem.

Cheers !

查看更多
Explosion°爆炸
3楼-- · 2020-05-14 14:24

I got a great solution.

This is the problem of new version of Android Studio. So downgrade this version to 2.3.3 https://developer.android.com/studio/archive.html

查看更多
Summer. ? 凉城
4楼-- · 2020-05-14 14:26

I was able to fix by running the following command in Terminal

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

enter image description here

After running that I was able to run this command successfully

ionic cordova build android --release 
查看更多
SAY GOODBYE
5楼-- · 2020-05-14 14:26

Changing the permissions of

/Applications/Android Studio App Path /Contents/gradle/gradle-..*/bin/gradle

查看更多
再贱就再见
6楼-- · 2020-05-14 14:27

I had the same issue, I solved it by running the command below in the app folder:

ionic hooks add
查看更多
欢心
7楼-- · 2020-05-14 14:28

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

/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.

查看更多
登录 后发表回答