Cordova android 构建立即失败 [错误:产生 EACCES]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20109929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cordova android build fails immediately [Error: spawn EACCES]
提问by glenatron
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
步骤分解为prepare
并且compile
据我所知,前者工作正常)我看到了这一点:
~/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. It looks as though it is trying to spawn another process - maybe the Android SDK? - and it is failing.
现在据我所知,这是一个权限问题,但我没有 Node 或 Cordova 经验,但我不知道如何解决它。看起来好像它正在尝试生成另一个进程 - 也许是 Android SDK?- 它正在失败。
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 whichprocess it can't start.
不幸的是,他们实际上似乎并没有提供更多信息,比如它无法启动哪个进程。
回答by Ricky Levi
For me, this has fixed it:
对我来说,这已经解决了:
chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle
chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle
回答by Carlos Luis Rojas Aragonés
It's a permission issue, just execute:
这是一个权限问题,只需执行:
chmod 777 "/media/glenatron/localdisk/Projects/Cordova/MyProject/platforms/android/cordova/build"
That should fix the problem.
那应该可以解决问题。
回答by Edward Newsome
Using verbose like Solidak suggested works.
使用像 Solidak 建议的那样冗长的作品。
cordova build --release --verbose android
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
那个文件并且它起作用了。
回答by solidak
Its different for every one, I guess. Running --verbose
would give you the file that Cordova needs access to. From there you can chmod 777 <file>
. The command you should run to figure out the inaccessible file looks like this: cordova build --release --verbose android
我猜每个人都不一样。运行--verbose
将为您提供 Cordova 需要访问的文件。从那里你可以chmod 777 <file>
。您应该运行以找出无法访问的文件的命令如下所示:cordova build --release --verbose android
回答by raghum
I was facing the same issue. In my case, I had put the sample cordova project on a different ext3 partition than home folder. Since the partition was not NTFS, permissions shouldn't have been a problem. 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 项目放在与主文件夹不同的ext3 分区上。由于分区不是 NTFS,权限应该不是问题。但是当我尝试了所有建议的方法(更改权限,使所有内容都可以执行)时,它们都不起作用。在我的主分区中创建示例cordova文件夹后,这个问题就消失了。
回答by Lokesh Deshmukh
For MAC users change the name from "Android Studio" to AndroidStudio. My cordova build was taking back slash() in name of android studio so i changed the name of app. It is working for me.
对于 MAC 用户,将名称从“Android Studio”更改为 AndroidStudio。我的cordova 版本以android studio 的名义收回了slash(),所以我更改了app 的名称。它对我有用。