cmd: Command failed with exit code ENOENT - android

I'm trying to use phonegap to make an android app, but it shows me this:
c:\Users\sshewale\Desktop\phone gap\hello>phonegap platform add android
npm
http GET https://registry.npmjs.org/cordova-android
npm http 304 https://registry.npmjs.org/cordova-android
Adding android project...
Error: cmd: Command failed with exit code ENOENT
at ChildProcess.whenDone (C:\Users\sshewale\AppData\Roaming\npm\node_modules
\phonegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.j
s:134:23)
at ChildProcess.emit (events.js:107:17)
at Process.ChildProcess._handle.onexit (child_process.js:1072:12)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
UPDATE: It Moved A Bit Ahead But Now It Shows This:
C:\Users\sshewale\hi>cordova platform add android
npm http GET https://registry.npmjs.org/cordova-android
npm http 200 https://registry.npmjs.org/cordova-android
npm http GET https://registry.npmjs.org/cordova-android
npm http 200 https://registry.npmjs.org/cordova-android
npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-4.0.2.
tgz
npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-4.0.2.
tgz
Adding android project...
Error: cmd: Command failed with exit code ENOENT
at ChildProcess.whenDone (C:\Users\sshewale\AppData\Roaming\npm\node_modules
\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
at ChildProcess.emit (events.js:107:17)
at Process.ChildProcess._handle.onexit (child_process.js:1072:12)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
C:\Users\sshewale\hi>
I'm not sure why this is happening, I don't remember changing any setting from the defaults.

Please add C:\Windows\System32 in your PATH variable

In a Windows environment:
If you have already installed cordova, do the following:
npm uninstall cordova -g or npm uninstall -g cordova
Delete folder .cordova
Right click your PC icon >> Properties
Control Panel >> Advanced System Properties >> Environment Variables...
Define C:\Windows\System32 as a System Variable(Bottom Window) ie SYSTEM_HOME
Then define %SYSTEM_HOME% in the Server Variables (Top Window)
BEFORE REINSTALLING cordova run the **** platform add android command
THEN run npm install -g cordova or npm install cordova -g
I've been working with ionic#beta and the ...platform add ... relies heavily on cordova so it is recommended to add the platforms BEFORE initiating cordova to minimize conflict.
Hope this helps.
**** = phonegap or ionic

Installation of CORDOVA
Install node
open CMD
node -v for checking version installed
npm -v for checking version installed
Npm install -g cordova
After Insatalling Android SDK
Open SDK manager (Download API LEVEL 23 & 24 only)
Set the Environment Variables of Android SDK:-
To add the SDK Tools to the PATH, open the Control Panel, click System and Security, click System, click Change settings, click the Advanced tab, then click the Environment Variables button.
In the list User variables select PATH and click the Edit button.
At the end of the field Variable value, add a semicolon followed by the path to the tools and platform-tools directores of the Android SDK install. Here is an example of what to add (note that there are two paths in one line, separated by a semicolon):
;C:\Users\anshu\AppData\Local\Android\android-sdk\tools;C:\Users\anshu\AppData\Local\Android\android-sdk\platform-tools
You can prepare the path in a text editor, copy it and paste at the end of the input field. Click the OK button when done.
Click the OK button again to close the Environment Variables window.
Now test the install. Close any open command windows, open a new command window and type:
adb version
This should display the version of the Android Debug Bridge.
Navigate to C:>cd Nodespace\Android
Type >>cordova create Test com.anshu.test Test
Type >>cd Test
Type >>cordova platform add android
Type >>cordova compile android
After Connecting Android Device in Debugging Mode to Your System VIA USB
Type>>cordova run

C:\Users\VinexN207>cordova platform add android
Error: Current working directory is not a Cordova-based project.
C:\Users\VinexN207>cd C:\Project\java_script\nShop
C:\Project\java_script\nShop>cordova platform add android
Error: Platform android already added.
C:\Project\java_script\nShop>cordova platforms ls
Installed platforms: android 5.1.1
Available platforms: amazon-fireos, blackberry10, browser, firefoxos, webos, win
dows, windows8, wp8
C:\Project\java_script\nShop>cordova platform add ios
WARNING: Applications for platform ios can not be built on this OS - win32.
Adding ios project...
iOS project created with cordova-ios#4.0.1
Installing "cordova-plugin-whitelist" for ios
C:\Project\java_script\nShop>cordova platforms ls
Installed platforms: android 5.1.1, ios 4.0.1
Available platforms: amazon-fireos, blackberry10, browser, firefoxos, webos, win
dows, windows8, wp8
C:\Project\java_script\nShop>
Yes, it works after adding path. Probably it works, because it doesn't write it Installed platforms: android-broken.

Try to follow these steps:
run
npm uninstall cordova -g
delete the folder C:\Users\your-name.cordova
reinstall the cordova: npm install cordova -g
go to the project folder and try again
cordova platform add android

Related

Running ionic apps in an Android Emulator.

I am new in ionic framework,and want to run the app I made into an Android emulator. I type this command,
ionic emulate android
and get this error.
Error: cmd: Command failed with exit code 1
I have all the path variables set up correctly I think.
PATH
C:\Program Files\Git\usr\local;C:\Users\W\AppData\Roaming\npm\node_modules\bower\bin;C:\Users\Theodosios\AppData\Roaming\npm;C:\Program Files (x86)\Java\jre1.8.0_111\bin
JAVA_OPTIONS
-Xmx512M
Any ideas what is wrong and how can it be fixed?
Thanks,
Theo.
Use this commands on console
npm install -g npm
npm install -g ionic cordova
npm install -g angular-cli
and setting the "Environment Variables"
JAVA_HOME
ANDROID_HOME
AVD
1) Options
Remove android platfrom and install again.
Remove platform
$ cordova platform remove android
Add Platform
$ cordova platform add android
2) Options
Open SDK manager => Run as administrator
You will require:
1) SDK Platform
2) Android SDK Platform-tools
3) Andoid SDK tools

Building Ionic app for Android on Linux fails with exit code 2: Failed to find 'ANDROID_HOME'

I'm trying to build a default example app on Linux/Ubuntu 14.04 for Android.
I get a standard error message when doing sudo ionic build android:
Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
(see full log down below)
But if I do
echo $ANDROID_HOME && echo $JAVA_HOME && echo $ANT_HOME
/home/user3123726/Android/Sdk
/usr/lib/jvm/java-8-oracle
/usr/bin/ant
And command android and cordova are also available.
Android SDK is installed with all platform targets currently available (plus Android SDK Tools,Platform-Tools and Build tools)
npm 3.3.9 and Node 4.2.2 is installed
Cordova 5.3.3 was installed via npm
Ionic 1.7.7 was installed via npm
Apache Ant 1.9.3
ANDROID_HOME also defined on .bashrc:
export ANDROID_HOME=/home/user3123726/Android/Sdk
export PATH=${PATH}:/home/user3123726/Android/Sdk/platform-tools:/home/user3123726/Android/Sdk/tools
I have no idea what is the reason that the build process fails. Any help is appreciated - thanks!
Here full log of ionic project creation (basically create,add platform and build):
ionic start myApp tabs
Downloading: https://github.com/driftyco/ionic-app-base/archive/master.zip
[=============================] 100% 0.0s
Downloading: https://github.com/driftyco/ionic-starter-tabs/archive/master.zip
[=============================] 100% 0.0s
Updated the hooks
directory to have execute permissions Update Config.xml Initializing
cordova project
Your Ionic project is ready to go! Some quick tips: [... shortened]
cd myApp
sudo ionic platform add android
Updated the hooks directory to have execute permissions
Downloading Default Ionic Resources
Downloading: https://github.com/driftyco/ionic-default-resources/archive/master.zip
[=============================] 100% 0.0s
Done adding default Ionic resources
Adding icons for platform: android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.myapp809922
Name: myApp
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.1.1
Running command:
/home/user3123726/testing/myApp/hooks/after_prepare/010_add_platform_class.js /home/user3123726/testing/myApp
add to body class: platform-android
Saving platform to package.json file
sudo ionic build android
Running command: /home/user3123726/testing/myApp/hooks/after_prepare/010_add_platform_class.js /home/user3123726/testing/myApp
add to body class: platform-android
Running command: /home/user3123726/testing/myApp/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/user3123726/testing/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/user3123726/testing/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 emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Fixed it:
Was a permission problem
sudo chown -R $(whoami) /home/user3123726/.cordova
to give cordova the rights
and did
ionic add platform android
ionic build android
without sudo ;)

ANDROID_HOME is not set and "android" command not in your PATH Phonegap

i have installed android bundle and i have configured everything in .bashrc file and even when i say android in command line .. i am getting android manager .. but when i say ionic platform add android i am always getting error as "Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions." . i tried many way but issue not fixed .
my platform :
Ubuntu 14.04 64 bit
.bashrc file :
export HOME="/home/system"
export ANDROID_HOME="$HOME/adt-bundle-linux-x86_64-20140702/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/adt-bundle-linux-x86_64-20140702/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export ANT_HOME="/usr/share/ant"
export PATH="$ANT_HOME/bin:$PATH"
export ANDROID_HOME="/home/system/adt-bundle-linux-x86_64-20140702/sdk/tools"
error while execution :
system#system-H81M-S1:/usr/share/nginx/www/myApp# ionic platform add android
npm http GET https://registry.npmjs.org/cordova-android/3.6.3
npm http 200 https://registry.npmjs.org/cordova-android/3.6.3
npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.3.tgz
npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.3.tgz
Creating android project...
/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:126
throw e;
^
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
at /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
at _fulfilled (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
at /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
at flush (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
Error: /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/
create: Command failed with exit code 8 at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/
cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
may i know how i can fix this error
I faced the same problem, and it's solved.
I think it's issue with the compatibility of the latest cordova with latest android.
As well as you've issue with the android home path.
In .bashrc file
export HOME="/home/indranil"
export ANDROID_HOME="$HOME/software/adt-bundle-linux-x86_64-20140702/sdk"
export PATH="$HOME/software/adt-bundle-linux-x86_64-20140702/sdk/tools:$ANDROID_HOME/platform_tools:$PATH"
Try to download the latest android SDK if you're using older version.
And download Android 4.4.2(API 19) from your android manager.
You can use the latest cordova (4.0.0) but if the issue is still there then use cordova (3.5.0-0.2.7), but if you want to upgrade or downgrade the cordova, remove the existing one using:-
npm uninstall -g cordova (If linux use sudo npm uninstall -g cordova)
If you are using linux don't use
sudo
commad at the time of installing cordoava, if you get any error, run the following commands
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
sudo chown -R `whoami` /usr/local
Then install cordova without sudo
npm install -g cordova#3.5.0-0.2.7
At the time of creating ionic app and adding android as platform don't use sudo command.
Cordova creates a .cordova directory in the home folder at the time of adding platform. Remove that directory before creating the new ionic application.
And after downloading the android(4.4.2), create an android virtual device using the command:
android avd
I have been struggling with this also (Ubuntu 14.04) and I remember accepting that just getting the cordova build command to work was too difficult for me :-). I was sure my PATHs were correct (tried root and user etc etc) and tried every solution I could find.
A comment by Stoicuta Alexandru On this page solved it for me. I quote:
If ANDROID_HOME is not set, cordova will search for it in home/android-sdk
So just putting my android sdk in the home-folder and (important) naming it android-sdk did it.
Hope to save some people some time...
I had the same problem but I found an alternative method i.e. using the Phonegap Developer App. You could install it to the emulator and use it.
In my case I first created the ionic app and ran other ionic commands using SUDO; that's why it was not working as sudo uses root profile.
This is how i fixed:
delete the /home/user1/.cordova (replace user1 with you user name)
i used "sudo rm" command to delete folder and all of its conents
i deleted the /home/user1/tmp folder so that when we run the cordova again it creates the new tmp folder with proper permission of current user
created new app using "ionic start app5" - this was the main issue as i previously was doing it with sudo
added platform using "ionic platform add android"
executed using "ionic run android"
remember that if from command line you can run "android" command and "java -version" command then above is perfect solution. let me know if you guys need any help from me.
After facing for many day with this issue i follow the instructions above and set my .bash_profile like this on MAC
#====================================================
export ANT_HOME=/usr/local/Cellar/ant/1.9.4/bin/ant
#
export HOME="/Users/User"
export ANDROID_HOME="$HOME/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk"
export PATH="$HOME/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/tools:$ANDROID_HOME/platform_tools:$PATH"
#
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${PATH}
#
export PATH=${PATH}:/Users/User/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/Users/User/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/User/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W
#
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
#
# Unset manpath so we can inherit from /etc/manpath via the manpath
# command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

phonegap run android - create Command failed with exit code 8 - linux

I did some googleing but find nothing approriate.
Any help appreciated. Try it with an naked vm to be sure
having no nodejs install or dependency issue.
Christian
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo npm install -g phonegap
sudo npm install -g cordova
sudo apt-get install ant
chris#mint16 ~/project/dev $ phonegap create my-app
[phonegap] create called with the options /home/chris/project/dev/my-app com.phonegap.helloworld HelloWorld
[phonegap] Customizing default config.xml file
[phonegap] created project at /home/chris/project/dev/my-app
chris#mint16 ~/project/dev $ cd my-app/
chris#mint16 ~/project/dev/my-app $ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
{ [Error: /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
I've just faced the same issue, the problem was that path to sdk tools was not properly setup:
So try the following:
export PATH=$PATH:/usr/local/adt-bundle/sdk/tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/platform-tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/build-tools
I also hit the same issue, but just adding the various android sdk tools directories to the path as DKMudrechenko suggested above did not help. It turned out that I had not installed ant properly. I had downloaded it from apache.org and just added the ant 'bin' folder to my path, but apparently that wasn't good enough. However, after removing that entry from my path statement and adding ant via brew, I was then able to build the android cordova project successfully using the 'cordova build android' command.
i have been facing this issue on and off only to realise that the build fails for other errors in the code/configuration.
the process you have taken does skip one part where the android platform is added
corodova platforms add android
in the steps given above, you have created a project, traversed into the project directory and then ran the build, to which the phone gap checked the installed sdks by checking ANDROID_HOME and tried to set up the project for android.
you might want to run it in a correct order:
create project
move to the project directory
add platform
build / run.
i hope this helps

cordova 3.4.0 installation error

I am trying to create project in cordova i am getting follwing error
C:\xampp\htdocs\tagcordova\sample>cordova -d platform add android'
Platform "android'" not recognized as a core cordova platform. See "platform lis
t".
C:\xampp\htdocs\tagcordova\sample>cordova -d platform add android
cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Creating android project...
Running command: cmd args=["/c","C:\\Users\\Bhanuprakash\\.cordova\\lib\\android
\\cordova\\3.4.0\\bin\\create","--cli","C:\\xampp\\htdocs\\tagcordova\\sample\\p
latforms\\android","com.tag.sample","Sample"]
Command finished with error code ENOENT: cmd /c,C:\Users\Bhanuprakash\.cordova\l
ib\android\cordova\3.4.0\bin\create,--cli,C:\xampp\htdocs\tagcordova\sample\plat
forms\android,com.tag.sample,Sample
Error: cmd: Command failed with exit code ENOENT
at ChildProcess.whenDone (C:\Users\Bhanuprakash\AppData\Roaming\npm\node_mod
ules\cordova\src\superspawn.js:112:23)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:795:12)
i follwed following article http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html
please tell me how to solve the problem.
If you are sure of yours paths try to type android in cmd, if it says: 'xcopy' was not recognized.
then add to your path:
%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
cordova -d platform add android'
try
cordova -d platform add android
Hi problem is with android sdk.
Ensure you are using adt-bundle-windows and set following environment path.
Start -> Control Panel -> System and Security -> System -> Environment variables -> System variables
ANDROID_HOME: C:\Nithi\software\Android_sdk\adt-bundle-windows-x86_64-20131030\adt- bundle-windows-x86_64-20131030\sdk\
path: "Existing path";%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
"Existing path": already system paths will be there.
delete .cordova and .android in C:\Users\youruser>
close command prompt and open.
phonegap run android or cordova platform add android
hope with will work!!!!

Categories

Resources