离子构建android,错误:产生EACCES

时间:2022-01-21 02:00:22

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?

我做错了什么?这是Ionic的一个错误吗?

[Edit]

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

运行离子构建android --verbose提供以下输出:

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

15 个解决方案

#1


81  

Got the same error today. Thanks to the comments above, here is how I fixed it.

今天得到了同样的错误。感谢上面的评论,这是我如何解决它。

Ran:

cordova build android --verbose

and it showed me where it got the "Permission Denied" error... In my case it was:

它告诉我它在哪里得到“权限被拒绝”错误...在我的情况下它是:

Running command: /usr/libexec/java_home
Command finished with error code 0: /usr/libexec/java_home
ANDROID_HOME=/Users/mj/phonegap/adt-bundle-mac-x86_64-20140321/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Running command: "/Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle"
 -p /Users/mj/EduceMobile/app/platforms/android wrapper -b /Users/mj/EduceMobile/app/platfo
rms/android/wrapper.gradle

To fix, ran:

要修复,运行:

sudo chmod 755 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle

...and

...
...
:cdvBuildDebug

BUILD SUCCESSFUL

Total time: 2 mins 44.195 secs

Hope it helps.

希望能帮助到你。

#2


11  

Above solutions didn't work for me. I solved error with this command:

以上解决方案对我不起作用。我用这个命令解决了错误:

chmod 755 platforms/android/gradlew

#3


10  

For those who gets similar error after updating Android Studio to version 3.x, you can run the following command to fix it:

对于将Android Studio更新到版本3.x后出现类似错误的用户,可以运行以下命令进行修复:

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

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

Hopefully it helps!

希望它有所帮助!

#4


8  

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

仅适用于OSX ---从finder转到Applications文件夹,只需删除之间的空格即可重命名Android Studio App Package名称。

Before : Android Studio After: AndroidStudio

之前:Android Studio After:AndroidStudio

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

默认情况下没有权限问题,只是空间是问题所在。

Cheers !

#5


6  

Just encountered the same issue, and I don't think it has anything to do with sudo - that command is simply missing the execute permission

刚刚遇到同样的问题,我认为它与sudo没有任何关系 - 该命令只是缺少执行权限

chmod +x hooks/after_prepare/010_add_platform_class.js

#6


6  

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

#7


2  

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

运行离子构建android --verbose提供以下输出:

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

更改/ Applications / Android Studio 2.4 Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle的权限可以解决问题。

#8


2  

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"

离子构建android,错误:产生EACCES

After running that I was able to run this command successfully

运行后,我能够成功运行此命令

ionic cordova build android --release 

#9


1  

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

我遇到了同样的问题,我通过在app文件夹中运行以下命令解决了这个问题:

ionic hooks add

#10


1  

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

这是新版A​​ndroid Studio的问题。因此将此版本降级到2.3.3 https://developer.android.com/studio/archive.html

#11


1  

My problem wasn't permissions... I couldn't quite find the origin of the problem but I did a workaround. this error was happening when I was trying to add a plugin which wasn't updated to the new files/folder system.

我的问题不是权限......我找不到问题的根源但我做了一个解决方法。当我尝试添加未更新到新文件/文件夹系统的插件时,会发生此错误。

cordova platform android -v

it returned -> 8.0.0

它返回 - > 8.0.0

What I did was:

我做的是:

cordova platform rm android
cordova platform add android@6.4.0

and then:

cordova plugin add <plugin>

This way the plugin installation showed no errors.. but keep in mind that after the cordova plugin add command, the android platform version automatically updated to 8.0.0 again... so I had to repeat the process in order to add another plugin with the same issue.

这样插件安装显示没有错误..但请记住,在cordova插件添加命令后,android平台版本再次自动更新到8.0.0 ...所以我不得不重复这个过程,以便添加另一个插件与同样的问题。

After repeating this process 2 times I finally got the project to run with the 2 plugins installed

重复此过程2次后,我终于让项目在安装了2个插件的情况下运行

#12


0  

Changing the permissions of

更改权限

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

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

#13


0  

it is a permission issue chmod cmd will help you

这是一个权限问题chmod cmd会帮助你

step 1: use cmd sudo cordova run android --verbose

第1步:使用cmd sudo cordova运行android --verbose

step 2: find below line it may vary on your install location:

第2步:找到以下行,它可能会因您的安装位置而异:

/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle

step 3: run cmd with your location

第3步:使用您的位置运行cmd

sudo chmod -R 777 /Applications/Android\ Studio.app

step 4: run cmd cordova build android

第4步:运行cmd cordova build android

#14


0  

run the cordova command with --verbose option. Do not prefix the command with ionic cordova. This will tell you where the access problem is. For me it was a problem where gradlew was installed on my system without execution privileges. Once i add execution ability to gradlew, the eaccess error went away.

使用--verbose选项运行cordova命令。请勿使用ionic cordova作为命令的前缀。这将告诉您访问问题的位置。对我来说这是一个问题,我的系统上没有执行权限就安装了gradlew。一旦我将执行能力添加到gradlew,eaccess错误就消失了。

#15


-1  

You have to fix the 'gradle' to be executable by your system account:

您必须修复“gradle”以使您的系统帐户可执行:

$ sudo chmod 755 /Applications/Android\ Studio.app/Contents/grad le/gradle-<VERSION>/bin/gradle

$ sudo chmod 755 / Applications / Android \ Studio.app/Contents/grad le / gradle- / bin / gradle

I had same trouble but now it's working for me.

我有同样的麻烦,但现在它对我有用。

#1


81  

Got the same error today. Thanks to the comments above, here is how I fixed it.

今天得到了同样的错误。感谢上面的评论,这是我如何解决它。

Ran:

cordova build android --verbose

and it showed me where it got the "Permission Denied" error... In my case it was:

它告诉我它在哪里得到“权限被拒绝”错误...在我的情况下它是:

Running command: /usr/libexec/java_home
Command finished with error code 0: /usr/libexec/java_home
ANDROID_HOME=/Users/mj/phonegap/adt-bundle-mac-x86_64-20140321/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Running command: "/Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle"
 -p /Users/mj/EduceMobile/app/platforms/android wrapper -b /Users/mj/EduceMobile/app/platfo
rms/android/wrapper.gradle

To fix, ran:

要修复,运行:

sudo chmod 755 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle

...and

...
...
:cdvBuildDebug

BUILD SUCCESSFUL

Total time: 2 mins 44.195 secs

Hope it helps.

希望能帮助到你。

#2


11  

Above solutions didn't work for me. I solved error with this command:

以上解决方案对我不起作用。我用这个命令解决了错误:

chmod 755 platforms/android/gradlew

#3


10  

For those who gets similar error after updating Android Studio to version 3.x, you can run the following command to fix it:

对于将Android Studio更新到版本3.x后出现类似错误的用户,可以运行以下命令进行修复:

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

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

Hopefully it helps!

希望它有所帮助!

#4


8  

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

仅适用于OSX ---从finder转到Applications文件夹,只需删除之间的空格即可重命名Android Studio App Package名称。

Before : Android Studio After: AndroidStudio

之前:Android Studio After:AndroidStudio

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

默认情况下没有权限问题,只是空间是问题所在。

Cheers !

#5


6  

Just encountered the same issue, and I don't think it has anything to do with sudo - that command is simply missing the execute permission

刚刚遇到同样的问题,我认为它与sudo没有任何关系 - 该命令只是缺少执行权限

chmod +x hooks/after_prepare/010_add_platform_class.js

#6


6  

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

#7


2  

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

运行离子构建android --verbose提供以下输出:

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

更改/ Applications / Android Studio 2.4 Preview.app/Contents/gradle/gradle-3.4.1/bin/gradle的权限可以解决问题。

#8


2  

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"

离子构建android,错误:产生EACCES

After running that I was able to run this command successfully

运行后,我能够成功运行此命令

ionic cordova build android --release 

#9


1  

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

我遇到了同样的问题,我通过在app文件夹中运行以下命令解决了这个问题:

ionic hooks add

#10


1  

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

这是新版A​​ndroid Studio的问题。因此将此版本降级到2.3.3 https://developer.android.com/studio/archive.html

#11


1  

My problem wasn't permissions... I couldn't quite find the origin of the problem but I did a workaround. this error was happening when I was trying to add a plugin which wasn't updated to the new files/folder system.

我的问题不是权限......我找不到问题的根源但我做了一个解决方法。当我尝试添加未更新到新文件/文件夹系统的插件时,会发生此错误。

cordova platform android -v

it returned -> 8.0.0

它返回 - > 8.0.0

What I did was:

我做的是:

cordova platform rm android
cordova platform add android@6.4.0

and then:

cordova plugin add <plugin>

This way the plugin installation showed no errors.. but keep in mind that after the cordova plugin add command, the android platform version automatically updated to 8.0.0 again... so I had to repeat the process in order to add another plugin with the same issue.

这样插件安装显示没有错误..但请记住,在cordova插件添加命令后,android平台版本再次自动更新到8.0.0 ...所以我不得不重复这个过程,以便添加另一个插件与同样的问题。

After repeating this process 2 times I finally got the project to run with the 2 plugins installed

重复此过程2次后,我终于让项目在安装了2个插件的情况下运行

#12


0  

Changing the permissions of

更改权限

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

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

#13


0  

it is a permission issue chmod cmd will help you

这是一个权限问题chmod cmd会帮助你

step 1: use cmd sudo cordova run android --verbose

第1步:使用cmd sudo cordova运行android --verbose

step 2: find below line it may vary on your install location:

第2步:找到以下行,它可能会因您的安装位置而异:

/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle

step 3: run cmd with your location

第3步:使用您的位置运行cmd

sudo chmod -R 777 /Applications/Android\ Studio.app

step 4: run cmd cordova build android

第4步:运行cmd cordova build android

#14


0  

run the cordova command with --verbose option. Do not prefix the command with ionic cordova. This will tell you where the access problem is. For me it was a problem where gradlew was installed on my system without execution privileges. Once i add execution ability to gradlew, the eaccess error went away.

使用--verbose选项运行cordova命令。请勿使用ionic cordova作为命令的前缀。这将告诉您访问问题的位置。对我来说这是一个问题,我的系统上没有执行权限就安装了gradlew。一旦我将执行能力添加到gradlew,eaccess错误就消失了。

#15


-1  

You have to fix the 'gradle' to be executable by your system account:

您必须修复“gradle”以使您的系统帐户可执行:

$ sudo chmod 755 /Applications/Android\ Studio.app/Contents/grad le/gradle-<VERSION>/bin/gradle

$ sudo chmod 755 / Applications / Android \ Studio.app/Contents/grad le / gradle- / bin / gradle

I had same trouble but now it's working for me.

我有同样的麻烦,但现在它对我有用。