cordova build android Command failed with exit code EACCES

问题:

执行cordova build android 出现输出如下,编译不成功。

ANDROID_HOME=/Users/huangenai/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home

/Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle: Command failed with exit code EACCES

 

 

探索过程

执行cordova build android --verbose

复制代码
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/huangenai/Desktop/project/push/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 "MyApp" to /Users/huangenai/Desktop/project/push/platforms/android/res/values/strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1
Wrote out Android package name "io.ionic.starter" to /Users/huangenai/Desktop/project/push/platforms/android/src/io/ionic/starter/MainActivity.java
Updating icons at platforms/android/res
Updating splash screens at platforms/android/res
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".
Running command: /usr/libexec/java_home
Command finished with error code 0: /usr/libexec/java_home
ANDROID_HOME=/Users/huangenai/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home
Running command: "/Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle" -p /Users/huangenai/Desktop/project/push/platforms/android wrapper -b /Users/huangenai/Desktop/project/push/platforms/android/wrapper.gradle
Command finished with error code EACCES: /Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle -p,/Users/huangenai/Desktop/project/push/platforms/android,wrapper,-b,/Users/huangenai/Desktop/project/push/platforms/android/wrapper.gradle
/Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle: Command failed with exit code EACCES
Error: /Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle: Command failed with exit code EACCES
    at ChildProcess.whenDone (/Users/huangenai/Desktop/project/push/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
复制代码

猜测gradle有问题

执行 gradle -version,有输出 gradle 已安装并配置了环境。

复制代码
------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------

Build time:   2018-11-26 11:48:43 UTC
Revision:     7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_191 (Oracle Corporation 25.191-b12)
OS:           Mac OS X 10.14 x86_64
复制代码

解决方案:

权限问题,执行以下命令,地址为上面红色那段中的地址

sudo chmod 777 "/Applications/Android Studio.app/Contents/gradle/gradle-4.6/bin/gradle"

 


此随笔乃本人学习工作记录,如有疑问欢迎在下面评论,转载请标明出处。

如果对您有帮助请动动鼠标右下方给我来个赞,您的支持是我最大的动力。

 

posted @   huangenai  阅读(2336)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
历史上的今天:
2017-01-02 JQuery 选择器
点击右上角即可分享
微信分享提示