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

问题描述 投票:5回答:5

过去几周我一直在使用cordova /离子项目。我用windows进行开发。但最近我不得不将我的开发环境改为Ubuntu。我使用Ubuntu 15.10。尝试在设置Android SDK之后在Ubuntu中构建相同的项目,JDK ANT等,给了我这个错误。我可以毫无问题地“离子服务”或“科尔多瓦服务”。尝试删除并重新添加平台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

检查了许可/所有权问题但没有找到任何问题。我可以编译一个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
android cordova ubuntu ionic-framework ionic
5个回答
12
投票

在我的android-sdk文件夹上递归chmod 765修复了它

感谢Muhsin寻求帮助:D

chmod 777 -R ~/android

1
投票

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

干杯。


0
投票

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

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

就我而言,它是/hooks/after_prepare/010_add_platform_class.js

所以我在像chmod-R 777 hooks这样的hooks文件夹上运行了chmod命令


0
投票

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

这对我有用,因为它的解释如下:here


-1
投票

这有点旧了,但今天我要处理一个旧项目,在我的情况下,我的Gradle模板丢失,所以我从Android Studio安装复制,但任何时候我都会运行cordova run android得到EACCES错误,我做的是

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

之后它工作正常