Cordova android build fails immediately [Error: spawn EACCES]

在学习Cordova时,build android平台时,遇到spawn EACCES错误,在网上找了几篇帖子,都说是权限问题,按照描述更改了各种提到的文件权限,始终没有解决。最后在stackoverflow找到了最好的解决方法。
本人用的时OS X系统,其他系统应该相同。另外本人机器上同时安装了android studio 3.0 preview和2.3两个版本,所以有两个gradle的版本,系统默认会调用最新版/最后安装的版本,所以使用以下命令可以找出具体出问题的:

cordova build –release –verbose android

输出如下:

No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at /Users/xxxx/Dev/workspace/cordova_ws/hello/platforms/android/res/xml/config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms/android/platform_www] to platforms/android/assets/www
Wrote out android application name "HelloWorld" to /Users/xxxx/Dev/workspace/cordova_ws/hello/platforms/android/res/values/strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000
Wrote out Android package name "com.example.hello" to /Users/xxxx/Dev/workspace/cordova_ws/hello/platforms/android/src/com/example/hello/MainActivity.java
This app does not have launcher icons defined
This app does not have splash screens defined
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=/Users/xxxx/Library/Android/sdk
JAVA_HOME=/Users/xxxx/Dev/JDK
Running command: "/Applications/Android Studio 3.0 Preview.app/Contents/gradle/gradle-4.1/bin/gradle" -p /Users/xxxx/Dev/workspace/cordova_ws/hello/platforms/android wrapper -b /Users/xxxx/Dev/workspace/cordova_ws/hello/platforms/android/wrapper.gradle
Error: spawn EACCES

然后在输出信息中(往往是最后几行)找到最后执行的文件,此处为

Running command: "/Applications/Android Studio 3.0 Preview.app/Contents/gradle/gradle-4.1/bin/gradle" -p /Users/xxxx/Dev/workspace/cordova_ws/hello/platforms/android wrapper -b 

修改此gradle执行文件的权限

 chmod 777 <file> 

再执行

cordova build android
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值