简体   繁体   English

Cordova android构建立即失败[错误:生成EACCES]

[英]Cordova android build fails immediately [Error: spawn EACCES]

I am just getting started with with Cordova ( PhoneGap ) and trying to build my first project with it, however I am running into a problem with my compilation step- when I try to build ( in tracking down the problem I broke down the build step into prepare and compile and the former works fine as far as I know ) I see this: 我刚刚开始使用Cordova(PhoneGap)并尝试使用它构建我的第一个项目,但是我遇到了编译步骤的问题 - 当我尝试构建时(在追踪问题时我打破了build步骤preparecompile ,前者的工作正常我知道)我看到这个:

~/Projects/MyProject$ cordova compile android
Compiling app on platform "android" via command "/media/glenatron/local disk/Projects/Cordova/MyProject/platforms/android/cordova/build" 
{ [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' }

Now from what I can tell this is a permissions problem, but having no Node or Cordova experience yet I am at a loss as to how to troubleshoot it. 现在从我可以看出这是一个权限问题,但没有Node或Cordova经验,但我不知道如何解决它。 It looks as though it is trying to spawn another process - maybe the Android SDK? 它看起来好像正在尝试产生另一个进程 - 也许是Android SDK? - and it is failing. - 它失败了。

Is there a way I can ask Node or Cordova to give me more information on what is going on or is there a log file somewhere that will help me to track down what the problem is? 有没有办法我可以让Node或Cordova给我更多关于发生了什么的信息,或者是否有某个日志文件可以帮助我找出问题所在?

Edit: I realised cordova has a --verbose switch and when I activated it I get the above output with an additional couple of lines... 编辑:我意识到cordova有一个--verbose开关,当我激活它时,我得到上面的输出另外几行......

Error: spawn EACCES
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

Unfortunately, they don't seem to actually give much more information, like which process it can't start. 不幸的是,他们似乎并没有实际上给更多的信息,像过程中它无法启动。

对我来说,这已经解决了这个问题:

chmod 777 /Applications/Android\\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle

It's a permission issue, just execute: 这是一个权限问题,只需执行:

chmod 777 "/media/glenatron/localdisk/Projects/Cordova/MyProject/platforms/android/cordova/build"

That should fix the problem. 这应该解决问题。

Using verbose like Solidak suggested works. 使用类似Solidak的详细建议作品。

cordova build --release --verbose android

The last command was to access /platforms/android/gradlew so i chmod +x that file and it worked. 最后一个命令是访问/platforms/android/gradlew所以我chmod +x那个文件,它工作。

Its different for every one, I guess. 我想,每个人都不同。 Running --verbose would give you the file that Cordova needs access to. 运行--verbose会为您提供Cordova需要访问的文件。 From there you can chmod 777 <file> . 从那里你可以chmod 777 <file> The command you should run to figure out the inaccessible file looks like this: cordova build --release --verbose android 您应该运行以找出无法访问的文件的命令如下所示: cordova build --release --verbose android

I was facing the same issue. 我面临同样的问题。 In my case, I had put the sample cordova project on a different ext3 partition than home folder. 在我的例子中,我将示例cordova项目放在与home文件夹不同的ext3分区上。 Since the partition was not NTFS, permissions shouldn't have been a problem. 由于分区不是NTFS,因此权限应该不是问题。 But when I tried all suggested methods (changing permissions, making everything executable), none of them worked. 但是,当我尝试所有建议的方法(更改权限,使所有可执行文件)时,它们都没有工作。 This problem went away as soon as I created the sample cordova folder in my home partition. 我在家庭分区中创建示例cordova文件夹后,此问题就消失了。

For MAC users change the name from "Android Studio" to AndroidStudio. 对于MAC用户,将名称从“Android Studio”更改为AndroidStudio。 My cordova build was taking back slash() in name of android studio so i changed the name of app. 我的cordova构建以android studio的名义取回了slash(),所以我更改了app的名称。 It is working for me. 它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM