0

I'm trying to build the default Hello World phonegap project for android on my ubuntu system, but I am confronted by errors at every step.

SHORT VERSION:

  1. I cannot create a phonegap project without sudo (not quite true--see below).
  2. After creating a phonegap project with sudo, I cannot build android without sudo.
  3. When I type "sudo phonegap build android", I lose my path settings, resulting in an error.
  4. I have attempted a fix for this last problem by including the line "alias sudo='sudo env PATH=$PATH'" in.bashrc, as suggested in sudo changes PATH - why?, but it doesn't work. I also added ANDROID_HOME and PATH lines to .bash_profile, with no success.
  5. I think the 'android' command actually is in my path.

Here are the last lines of my .bashrc:

export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
alias sudo='sudo env PATH=$PATH'

I also have the following in ~/.bash_profile:

export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"

LONG VERSION:

gregory@gregory-1001PXD:~/javascript$ phonegap create phonetest


Error: EACCES, permission denied '/home/gregory/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.

    at Object.fs.openSync (fs.js:432:18)
    at Object.fs.readFileSync (fs.js:286:15)
    at Object.create.all.get (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:34:26)
    at Object.Configstore (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:27:44)
    at new UpdateNotifier (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:34:17)
    at module.exports (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:123:23)
    at checkForUpdates (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:64:20)
    at cli (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:114:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/node_modules/cordova/bin/cordova:41:1)
    at Module._compile (module.js:456:26)


gregory@gregory-1001PXD:~/javascript$ sudo phonegap create phonetest
[sudo] password for gregory: 
Creating a new cordova project.
gregory@gregory-1001PXD:~/javascript$ cd phonetest/
gregory@gregory-1001PXD:~/javascript/phonetest$ sudo phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /home/gregory/javascript/phonetest/icon.png


Running command: /home/gregory/javascript/phonetest/platforms/android/cordova/build 

[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]

ERROR building one of the platforms: Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project

Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2

Bu I think the android command is in my PATH (it tab-completes).

NOTE: I can create a project without sudo if I remove the file update-notifier-cordova.json. But it still produces an error, as follows.

gregory@gregory-1001PXD:~/javascript$ sudo mv /home/gregory/.config/configstore/update-notifier-cordova.json ~/Documents/
gregory@gregory-1001PXD:~/javascript$ phonegap create phonetest
Creating a new cordova project.

gregory@gregory-1001PXD:~/javascript$ cd phonetest/
gregory@gregory-1001PXD:~/javascript/phonetest$ phonegap build android
[phonegap] executing 'cordova platform add --save android'...
Error: Failed to fetch platform android@~4.1.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES, open '/home/gregory/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore'

[phonegap] executing 'cordova build android'...
Error: No platforms added to this project. Please use `cordova platform add <platform>`.
Community
  • 1
  • 1
Gregory
  • 26
  • 1
  • 1
  • 10

1 Answers1

0

This is documented in their JIRA: https://issues.apache.org/jira/browse/CB-10062

Check the ownership of the file using:

ls -al /home/gregory/.config/configstore/update-notifier-cordova.json

If it is root, you may want to try reinstalling cordova - otherwise use the workaround suggested by running:

chmod 744 /home/gregory/.config/configstore/update-notifier-cordova.json

Stuart Ervine
  • 1,024
  • 13
  • 15