cordova build android Command failed with exit code EACCES
程序员文章站
2022-05-03 11:41:09
问题: 执行cordova build android 出现输出如下,编译不成功。 ANDROID_HOME=/Users/huangenai/Library/Android/sdkJAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jd ......
问题:
执行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"
此随笔乃本人学习工作记录,如有疑问欢迎在下面评论,转载请标明出处。
如果对您有帮助请动动鼠标右下方给我来个赞,您的支持是我最大的动力。