过去几周我一直在使用cordova /离子项目。我用windows进行开发。但最近我不得不将我的开发环境改为Ubuntu。我使用Ubuntu 15.10。尝试在设置Android SDK之后在Ubuntu中构建相同的项目,JDK ANT等,给了我这个错误。我可以"离子服务"或者" cordova服务"没有任何问题。尝试删除并重新添加平台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
答案 0 :(得分:12)
在我的android-sdk文件夹上递归chmod 765修复它
感谢Muhsin寻求帮助:D
chmod 777 -R ~/android
答案 1 :(得分:1)
chmod 755 -R~ / android也做到了。没有充分的理由让整个文件夹成为世界可写的。
干杯。
答案 2 :(得分:0)
因此,基本概念是更改平台命令尝试运行的文件夹的权限。
在构建过程中,错误消息突出显示构建失败的文件夹
就我而言,它是/hooks/after_prepare/010_add_platform_class.js
所以我在钩子文件夹上运行chmod命令,如chmod-R 777 hooks
答案 3 :(得分:0)
sudo chmod -R 777~ / android-studio / gradle / gradle-4.1 / bin / gradle
这对我来说是如何解释的: here
答案 4 :(得分:-1)
这有点旧了,但是今天我在我的情况下使用了一个旧项目我丢失了Gradle模板所以我从Android Studio安装中复制了,但是任何时候我都会运行{{1得到EACCES错误,我做的是
cordova run android
之后它工作正常