Cannot build cordova project, PATH error

while running cordova build from my application directory, I get the following error

[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/shakir/Documents/myapp/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/shakir/Documents/myapp/platforms/android/cordova/build: Command failed with exit code 2 at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Process.ChildProcess._handle.onexit (child_process.js:810:5)

I installed the ~/.profile file as follows

export ANDROID_HOME="/usr/local/android-sdk-linux"

export ANDROID_PLATFORM_TOOLS="/usr/local/android-sdk-linux/platform-tools"

export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS

and echo ANDROID_HOME give the following results

/usr/local/android-sdk-linux

I am using Ubuntu 14.04. How to solve this problem and create cordova applications?

+8
source share
4 answers

This error occurs because you set your sdk path for Android incorrectly. First find the android-sdk folder located on your computer. Inside the android-sdk folder there is a folder called "platform-tools". This way you can correctly identify the android-sdk folder. Then enter the path to the android-sdk folder. Now open a terminal and enter the following command:

 export ANDROID_HOME="your android-sdk path" 

Now run the project.

+13
source

you probably used "sudo" to add the Android platform. A quick fix to this problem:

  • Restore access rights to all folders / subfolders in the platforms folder

  • Remove Android platform with sudo cordova platform remove android

  • Add the android platform with cordova platform add android DO NOT USE THE COURT! If there are errors without Sudo SO, then the problem! NEVER use the sudo thing, otherwise the project will have the same problem!

If you still have a problem, you can install the cord using sudo, there is also a solution for it:
we must first configure npm for global installation so that we can use it without sudo, the preferred way to enable npm to install packages around the world without exiting $ HOME is to set the local node prefix. It is as simple as running:

 echo prefix = ~/.node >> ~/.npmrc echo 'export PATH=$HOME/.node/bin:$PATH' >> ~/.bashrc . ~/.bashrc 

then run:

 npm install -g cordova 

this may result in:

 Error: EACCES, permission denied '/home/yourusername/.config/configstore/update-notifier-cordova.json' 

To fix this:

 sudo chown yourusername:yourusername /home/yourusername/.config/configstore/update-notifier-cordova.json 

After that, you can happily run npm install -g cordova without sudo without running into permission conflicts, and if something is completely broken and you want to start from scratch, all you have to do is delete the ~ / .node directory.

Hope this help!

you can also look at these two links: source 1 & 2

+6
source

Run the following command in terminal:

export PATH = $ {PATH}: / Users / Document / Android-sdk / tools: / Users / Documents / Android-sdk / platform-tools

0
source

You may also get this error.

 Error: EACCES: permission denied, open '/home/yourusername/.cordova/lib/npm_cache/cordova-android/5.1.1/package/.npmignore' 

to fix this use this command

 sudo chown -R yourusername:yourusername /home/{username}/.cordova/lib/npm_cache/cordova-android/5.1.1/package 
-1
source

All Articles