错误:尝试在Ubuntu 15.10中构建Ionic应用时产生EACCES

时间:2021-07-21 22:59:49

I was was working with an cordova/ionic project for past couple of weeks. I used windows for development. But recently I had to change my developing environment to Ubuntu. I use Ubuntu 15.10. Tried to build the same project in Ubuntu after setting up Android SDK , JDK ANT ect., gave me this error. I can "ionic serve" or "cordova serve" without any problem. Tried removing and re adding the platform android but the issue was same. Below is the error.

在过去的几个星期里,我一直在和一个科尔多瓦/离子项目合作。我使用windows进行开发。但最近我不得不将我的开发环境改为Ubuntu。我使用Ubuntu 15.10。在安装了Android SDK JDK ANT ect之后,尝试在Ubuntu中构建相同的项目。给了我这个错误。我可以“服务”或“科尔多瓦服务”,没有任何问题。尝试删除并重新添加android平台,但问题是一样的。下面是错误。

user@myhost:~/works/myproject$ ionic build android
Running command: /home/user/works/myproject/hooks/after_prepare/010_add_platform_class.js /home/user/works/myproject
add to body class: platform-android
Running command: /home/user/works/myproject/hooks/after_prepare/020_remove_sass_from_platforms.js /home/user/works/myproject
Running command: /home/user/works/myproject/platforms/android/cordova/build 
ANDROID_HOME=/home/user/android
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Running: /home/user/works/myproject/platforms/android/gradlew cdvBuildDebug -b /home/user/works/myproject/platforms/android/build.gradle -Dorg.gradle.daemon=true
error caught: Error: spawn EACCES
/home/user/works/myproject/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                    ^

Error: spawn EACCES
    at exports._errnoException (util.js:874:11)
    at ChildProcess.spawn (internal/child_process.js:298:11)
    at Object.exports.spawn (child_process.js:339:9)
    at module.exports (/home/user/works/myproject/platforms/android/cordova/lib/spawn.js:37:35)
    at /home/user/works/myproject/platforms/android/cordova/lib/build.js:370:24
    at _fulfilled (/home/user/works/myproject/platforms/android/cordova/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/home/user/works/myproject/platforms/android/cordova/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/home/user/works/myproject/platforms/android/cordova/node_modules/q/q.js:760:13)
    at /home/user/works/myproject/platforms/android/cordova/node_modules/q/q.js:821:14
    at flush (/home/user/works/myproject/platforms/android/cordova/node_modules/q/q.js:108:17)
ERROR building one of the platforms: Error: /home/user/works/myproject/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /home/user/works/myproject/platforms/android/cordova/build: Command failed with exit code 1

Checked for permission/ownership issues but didn't find any. I can compile a java file therefore not a problem with my jdk. Here is my ionic info

检查权限/所有权问题,但没有找到。我可以编译java文件,因此我的jdk没有问题。这是我的离子信息

Cordova CLI: 5.4.0
Ionic CLI Version: 1.7.8
Ionic App Lib Version: 0.6.4
OS: Distributor ID: Ubuntu Description: Ubuntu 15.10 
Node Version: v4.2.2

5 个解决方案

#1


12  

Having a chmod 765 recursively on my android-sdk folder fixed it

我的android-sdk文件夹上有一个chmod 765递归地修复了它

Thanks to Muhsin for Help :D

感谢穆辛的帮助:D

chmod 777 -R ~/android

#2


1  

chmod 755 -R ~/android also did it. No good reason to make the whole folder world-writeable.

chmod 755 -R ~/android也这么做了。没有理由让整个文件夹成为世界可写的。

Cheers.

欢呼。

#3


0  

So the basic concept is to change the permissions on the folder for which the platform command is trying to run.

因此,基本概念是更改平台命令试图运行的文件夹的权限。

During the build process the error message highlights the folder for which the build is failing

在构建过程中,错误消息突出显示了构建失败的文件夹

In my case it was /hooks/after_prepare/010_add_platform_class.js

在我的例子中,它是/hook /after_prepare/010_add_platform_class.js。

So i ran the chmod command on the hooks folder like chmod-R 777 hooks

所以我在钩子文件夹上运行了chmod命令比如chmod- r777钩子

#4


0  

sudo chmod -R 777 ~/android-studio/gradle/gradle-4.1/bin/gradle

sudo chmod - r777 ~/android-studio/gradle/ 4.1级/bin/gradle

This worked for me as how this has been explained in : here

这对我起了作用,就像在《这里》中解释的那样

#5


-1  

This is a bit old, but today I've to work with an old project in my case I the Gradle template was missing so I copied from Android Studio installation but anytime I'll run the cordova run android get the EACCES error, what I did was

这有点旧了,但是今天我要处理一个旧的项目,在我的例子中,我的等级模板丢失了,所以我复制了从Android Studio安装,但是任何时候我运行cordova运行Android得到EACCES错误,我做的是

cp -r ${android_studio_installation}/plugins/android/lib/template ${android_sdk}/tools/
chmod +x ${android_sdk}/tools/templates/gradle/wrapper/gradlew

After that it's working fine

在那之后一切正常

#1


12  

Having a chmod 765 recursively on my android-sdk folder fixed it

我的android-sdk文件夹上有一个chmod 765递归地修复了它

Thanks to Muhsin for Help :D

感谢穆辛的帮助:D

chmod 777 -R ~/android

#2


1  

chmod 755 -R ~/android also did it. No good reason to make the whole folder world-writeable.

chmod 755 -R ~/android也这么做了。没有理由让整个文件夹成为世界可写的。

Cheers.

欢呼。

#3


0  

So the basic concept is to change the permissions on the folder for which the platform command is trying to run.

因此,基本概念是更改平台命令试图运行的文件夹的权限。

During the build process the error message highlights the folder for which the build is failing

在构建过程中,错误消息突出显示了构建失败的文件夹

In my case it was /hooks/after_prepare/010_add_platform_class.js

在我的例子中,它是/hook /after_prepare/010_add_platform_class.js。

So i ran the chmod command on the hooks folder like chmod-R 777 hooks

所以我在钩子文件夹上运行了chmod命令比如chmod- r777钩子

#4


0  

sudo chmod -R 777 ~/android-studio/gradle/gradle-4.1/bin/gradle

sudo chmod - r777 ~/android-studio/gradle/ 4.1级/bin/gradle

This worked for me as how this has been explained in : here

这对我起了作用,就像在《这里》中解释的那样

#5


-1  

This is a bit old, but today I've to work with an old project in my case I the Gradle template was missing so I copied from Android Studio installation but anytime I'll run the cordova run android get the EACCES error, what I did was

这有点旧了,但是今天我要处理一个旧的项目,在我的例子中,我的等级模板丢失了,所以我复制了从Android Studio安装,但是任何时候我运行cordova运行Android得到EACCES错误,我做的是

cp -r ${android_studio_installation}/plugins/android/lib/template ${android_sdk}/tools/
chmod +x ${android_sdk}/tools/templates/gradle/wrapper/gradlew

After that it's working fine

在那之后一切正常