How to fixed "cordova platform add android" error in ionic - ionic2

I am trying to add an Android platform for my ionic 2 projects using "ionic cordova platform add android". But it gives "[ERROR] An error occurred while running subprocess cordova." Any solution?

I would try to reinstalling cordova.
npm uninstall -g cordova
npm install -g cordova
I hope this help

Related

Visual Studio 2017 iOS Build Failed to acquire Cordova

I am building a mobile app using VS-TACO and I am trying to run my build on iOS.
When I try to build this app for iOS on a Windows host which is connected to a Mac with remotebuild agent, then I get following Error Message in Visual Studio 2017 on Windows Machine
"Remote build error from the build server
https://macIpAddress:3000/cordova - Error: Failed to acquire Cordova
version 6.3.1. TACO0204: Error installing cordova via npm. Exit Code:
1. See output for details. EShopper"
When i do "npm cordova -v" on my Mac, i see "5.4.2"
Windows OS: Windows 10
Mac OS Sierra
I have given all required user permissions as suggested in taco.visualstudio
Making npm cordova -v equals npm -v. It returns the npm's version, not the cordova version.
Cordova has to be installed on your PC(WINDOWS).
Could you do on your PC: cordova -v?
If nothing is return : npm install -g cordova#6.3.1 or npm install -g cordova#latest if you want the LATEST version of cordova.
Then you have to tell Visual studio to use the global version of cordova, for that: choose Global Cordova option in Config.xml editor UI.
Tell me if it's better, otherwise i'll guide you.

Ionic CLI not uninstalling

This is related to my previous question here which was never resolved. I am trying to fix the problem by doing a fresh reinstall of Ionic.
I first tried uninstalling Ionic with sudo npm uninstall -g ionic, and it completes with no errors, but doing ionic -v still outputs 2.1.1, so obviously it didn't really get uninstalled. After that I tried sudo npm install -g ionic#latest, and my problem still persists.
What is even weirder is what happened when I tried to create a new project from scratch to test it. I did ionic start test --v2 on my Ubuntu machine, and doing ionic serve still does the same thing that I stated in my previous question.
npm uninstall -g ionic
npm uninstall -g #ionic/cli
finally i was able to uninstall with this...
I had the same issue for resolving this
Run npm uninstall -g ionic
Go to the location "/usr/local/bin/"
Delete Ionic File
Close terminal
Open new terminal and run "npm uninstall -g ionic"
Now run "ionic -v"
This probably happens due to multiple installations of ionic in your machine, more so this happens on windows.
Run:
"where ionic" in your command prompt
if it does not work try :
"which ionic" !! (probably linux)
This will give you the location of your installed ionic, in windows its mostly ..Local\AppData\Roaming.. somewhere.
Go to that location delete ionic and ionic.cmd file there.
Run: ionic -v now, make sure it gives you an error.
Be Happy if you see error.
run: npm install ionic#latest -g now
Run: ionic -v, make sure you see your latest ionic version there.
Be more happy now.
Uninstall cordova and ionic.
npm uninstall -g cordova
npm uninstall -g ionic
Then check to make sure you have the right version:
ionic -v
Use this command please
npm uninstall -g #ionic/cli
What is your node and npm versions ?
Please update latest node js (https://nodejs.org/en/download/current/)
then check that
node -v
npm -v
Node version must be v8.5.0 (includes npm 5.3.0) and then
sudo npm uninstall -g ionic
sudo npm cache clean --force
sudo npm install ionic
check the ionic version
ionic -v
version will be ^3.10.1. If everything is ok you can use new project command as given below
ionic start --list
you can see what kind of project types here as an example
ionic start blank
You can try running the command as below, it worked for me:
sudo npm uninstall -g #ionic/cli
If you are checking the ionic version inside project folder then
try to remove the ionic cli without -g option. It may be possible that you have installed local version of ionic inside project.
If you're using nvm, remember to delete ionic from where ionic. I deleted it via nvm uninstall {{version}}.

"ionic cordova build android" fails to buld apk

I have set all the required environments. To confirm i checked the requirements to build android using command
cordova requirements
which gave the result as below
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-25,android-24,Google
Inc.:Google APIs:24,android-23
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle
when i tried to build apk using command
ionic cordova build android
am getting as below
> ionic cordova prepare
> cordova prepare
- Running command [12:17:44] lint finished in 4.70 s
√ Running command - done!
> cordova build android
× Running command - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):
ANDROID_HOME=C:\Users\Arunkumar.DESKTOP-59TSCLF\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
The system cannot find the path specified.
Error: cmd: Command failed with exit code 1
Previously I had also faced this problem. I solved my problem by this way. I have installed Gradle in C:\Program Files\gradle\gradle-3.3. I set the Gradle path like that
GRADLE_HOME C:\Program Files\gradle\gradle-3.3
Add Path C:\Program Files\gradle\gradle-3.3\bin

How to create ionic 2 app

i am new to ionic2 and not able to create ionic2 app
if i run this command
it will create ionic3
$ npm install -g ionic cordova
i am getting error if i run this command
npm install -g ionic#2.3.0
error
npm ERR! code ETARGET
npm ERR! notarget No matching version found for ionic#2.3.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\abc\AppData\Roaming\npm-cache\_logs\2017-07-25T08_11_14_543Z-debug.log
ionic 2.2.3 doesn't exist, after releasing ionic 2.2.0, ionic cli version moved to 3.0.0.
npm install -g ionic#2.2.0 will work.
And to create ionic 2 project you need to change version of ionic-angular in you project, not in ionic-cli.
Ionic framework (ionic-angular) and ionic-cli both are different.
CHANGELOG v2.x.x.
CHANGELOG v3.x.x.
Refer this a link! to know the difference between ionic and ionic-angular and
to create ionic2 refer this a link!

Unable to install ionic2 on Mac OS by installing node and npm also

unable to install ionic 2
Successfully Installed ionic2#beta using
sudo npm install -g ionic#beta
ionic -v shows version 1.7.14
Uninstalled using npm uninstall -g ionic
Successfully (based on printout) uninstalled ionic 2
ionic -v shows version 1.7.14 (WTF)
Tried npm uninstall -g ionic again
Received command prompt immediately, no other outputs (no affect)
ionic -v shows version 1.7.14
You have 2 choices.
As comment suggests do:
sudo npm install -g ionic#beta
You will have to do this for every global command as you dont have permission to the folders.
Or
Check npm fix permission issue
You can change the global node module directory of npm so that you wont need permission. You can also use app like homebrew to set up your node.