0

While i try to add an android platform in my Phonegap project i get this error

Failed to install 'cordova-plugin-whitelist':Error: <project_path>/platforms/android/cordova/version: Command failed with exit code EACCES
    at ChildProcess.whenDone (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.emit (events.js:95:17)
    at Process.ChildProcess._handle.onexit (child_process.js:818:12)

And i try do some of this link solutions like give permission to build and remove the android platform and add it again but every time i get the same error

What is the potential solution ?

Community
  • 1
  • 1
ahmad soliman
  • 141
  • 1
  • 2
  • 14

2 Answers2

0

As per documentation there is no need to run cordova platform add android as root. Check the example:

$ cordova create hello com.example.hello HelloWorld
$ cd hello
$ cordova platform add android
$ cordova build

If you still face any issue check that executable scripts or programs are allowed to be executed.

In your case I'd guess that cordova tries to run

<project_path>/platforms/android/cordova/version

what is probably not allowed to be executed. So call

sudo chmod ugo+x <project_path>/platforms/android/cordova/version

to make version executable.

p.s.: updated my answer above. Some days ago I tested for another post what happens, if I added the platform as root. Though it was another issue there I saw that it is not required to run cordova platform add android as root.

I think it's only the basic installation of Cordova that requires root. Everything else should be set up and executed as a normal user.

Community
  • 1
  • 1
Trinimon
  • 13,839
  • 9
  • 44
  • 60
  • Is this after adding ? because when i call "phonegap platforms ls" it returns "Installed platforms: android broken" – ahmad soliman May 14 '15 at 18:11
  • Ok, I double checked it: usually there is no need to run `cordova platform add android` as `root`. May be you got errors due to the fact that you added is as `root`. I'll update my answer accordingly ... – Trinimon May 14 '15 at 18:17
  • (( $ phonegap build )) i get this error "Command failed with exit code EACCES You may not have the required environment or OS to build this project" – ahmad soliman May 14 '15 at 21:13
  • When i call "phonegap platform add android" without root it returns Platform android already added. but its broken, and i try to delete android from platform and add it again without root also it return the same error above in the question – ahmad soliman May 15 '15 at 00:18
  • Did you check the _executable_-flag of `/platforms/android/cordova/version`? See https://issues.apache.org/jira/browse/CB-7033: _"One way is for a script/file which your version script depends on to go missing/lose its execute bit. ..."_ – Trinimon May 15 '15 at 06:58
0

I don't know what was the problem but i work on linux/ubuntu and i try to create an application at Home, and that issues disappeared, i think is depends on permission or mounting the disk!.

ahmad soliman
  • 141
  • 1
  • 2
  • 14