Running ionic apps in an Android Emulator. - android

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

Related

Ionic 3 Android build error

I am using Ionic 3. Right now I'm trying to do ionic cordova build android , but I get TypeError: env.runcmd is not a function (please see the photo attached).
I tried to:
-> ionic cordova platform rm android then ionic cordova platform add android then again build android again
-> delete node_modules folder and do npm install then build android again
But none of them helped it...
My ionic info output:
Just use command 'cordova run android' instead of 'ionic cordova run android'.
Okay, guys, the problem was exactly with cordova version. I haven't noticed when it did update to the version 7.0.1. However, I had to downgrade it to version 6.5.0 and then android build succeeded.
The only thing that confused me was the downgrade process. Every time I did sudo npm uninstall cordova -g, the cordova command was still available at bash. If I would do sudo npm install cordova#6.5.0 -g, the version still remained 7.0.1. Even some other commands such as ... --save --save-exact ... did NOT work.
So below are the steps which I've gone through to solve this issue (I am using Ubuntu linux, so this will work for linux users only).
First I uninstalled cordova through npm
sudo npm uninstall cordova -g
Then removed the program from local bin
sudo rm /usr/local/bin/cordova
Installed the specific version of cordova
sudo npm install cordova#6.5.0 -g (or whatever version you want)
And lastly, I have to admit that after cordova installation, it was now located at /usr/bin/cordova, no more at /usr/local/bin/cordova, so I had to create a hard link to it.
sudo ln -s /usr/local/bin/cordova /usr/bin/cordova
VoilĂ !

Cordova not recognized as external command inside project folder?

I have cordova installed in my npm folder. After cd Project_name in command line and tying cordova add platform i am getting an error
"Cordova is not recognized as internal or external command"
. I don't know what is wrong is here. I followed each step given on cordova documnentation. Below is a screenshot of the error
First check everything you have installed:
node - v
cordova -v
if these are not installed then, install it first.
Download and install NodeJS from here: https://nodejs.org/en/
Then check again node -v
If you have installed node successfully then install cordova.
npm install -g cordova
and then check cordova -v
I suggest that you will take a tour of getting started with cordova: http://cordova.apache.org/#getstarted
Try reinstalling the cordova using:
npm install -g cordova
After this you will able to add the platform.
I think you haven't set Environment Variable for the node JS.
Please follow steps which are provided in this link.
delete "platform" folder
Try add re-platform :
npm install -g cordova
or
Try reinstalling the cordova using:
npm install -g cordova
The Below steps helped me out:
Install Cordova using: npm install -g cordova
Check if Cordova is installed: To check go to "C:\Users\your username\AppData\Roaming\npm\node_modules" and search for Cordova folder. If it does not exists then in CMD run 'npm install -g cordova' to install cordova or reinstall npm and run 'npm install -g cordova'.
Environment variable PATH Exists: To check go to Environment variable (My Computer OR My PC > Right Click > Properties > Advance System Settings > Environemnts Variable button)
add
%appdata%\npm\ or c:\users\YourUserName\AppData\Roaming\npm
(replace YourUserName with the name of your user profile) to System Variable's PATH
Below are the screenshots step by step actions on Environment PATH.

Can't execute ionic application in genymotion

I try to execute an application implemented using Ionic within the Genymotion Android emulator.
To create my application, I did the following:
$ ionic start myApp blank
$ ionic platform android
$ ionic run android
Notice that I executed the last command after having started a virtual terminal (Sony Xperia Z for example).
I have the following error:
Running command: /(...)/myApp/hooks/after_prepare/010_add_platform_class.js /(...)/myApp
add to body class: platform-android
Running command: /(...)/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: /(...)/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: /(...)/myApp/platforms/android/cordova/build: Command failed with exit code 2
I don't understand why I need to have an ANDROID_HOME set since it's not the thing I want to use...
I installed then an Android SDK and set the ANDROID_HOME environment variable:
export ANDROID_HOME=/home/(...)/android-sdk-linux/
Then I have the following error:
$ ionic run android
Running command: /(...)/myApp/hooks/after_prepare/010_add_platform_class.js /(...)/myApp
add to body class: platform-android
Running command: /(...)/myApp/platforms/android/cordova/run
ERROR: Error: Please install Android target: "android-22".
Hint: Open the SDK manager by running: /home/(...)/android-sdk-linux/tools/android
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
ERROR running one or more of the platforms: Error: /(...)/myApp/platforms/android/cordova/run: Command failed with exit code 2
You may not have the required environment or OS to run this project
What isn't clear to me is how to tell Cordova to use Genymotion instead of the default Android emulator...
For information, I installed ionic and cordava like this:
$ sudo npm install ionic -g
$ sudo npm install cordova -g
I'm working on Linux Mint 17 Qiana / Cinnamon 64-bit.
Thanks very much in advance for your help!
Thierry
From the logs it doesn't look like a problem with the emulator/Genymotion but a problem with not having the Android SDK installed. Because of the licenses involved you typically need to install the Android SDK yourself.
This explains the error messages:
It first looks for where the SDK is installed, which is indicated by ANDROID_HOME. It errors since it's initially unset.
Once it's set, it can't find the right SDKs (android-22, platform-tools, tools) since they're not installed.

cmd: Command failed with exit code ENOENT

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

Cordova Plugins Installation MAC

I am using Cordova 3.3.0 and I want to install the camera and network plugins. In netbeans it is very simple to do so but I can't understand how this can be accomplished on MAC. Please note that I am very new to this.
I am trying to run the following command in the terminal:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
An error is saying
-bash: cordova: command not found
Can anyone guide me what needs to be done?
Thanks
If Cordova is well installed on your Mac, you need to add "/usr/local/share/npm/bin" directory to your $PATH variable. Open your Terminal / Command line and type:
export PATH=$PATH:/usr/local/share/npm/bin
Else, before install Cordova typing :
npm install -g cordova

Categories

Resources