I had an older Ionic app, it was built a little bit ago, and I wanted to update some of it and reset the state. I updated the Ionic CLI and Cordova, and then I also did a state reset by doing: sudo ionic state reset
Every time I do this I receive this I receive the same error when it tries to update the Ionic keyboard plugin. This error never shows up if I do a state reset before updating the CLI, but it only shows up after. Tried manually adding and removing the plugin but it doesn't show up when using cordova plugins list Any help would be nice. Here's the error:
Removed platforms and plugins
Attempting to restore your Ionic application from package.json
Restoring Platforms
cordova platform add browser
cordova platform add ios
Restore platforms is complete
Restoring Plugins
cordova plugin add cordova-plugin-device
cordova plugin add cordova-plugin-console
cordova plugin add cordova-plugin-splashscreen
cordova plugin add com.ionic.keyboard
/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/state.js:543
throw 'Error executing "' + pluginCommand + '":\n' + output;
^
Error executing "cordova plugin add com.ionic.keyboard":
Fetching plugin "com.ionic.keyboard" via npm
Error: Failed to fetch plugin com.ionic.keyboard via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: Registry returned 404 for GET on https://registry.npmjs.org/com.ionic.keyboard
If you target Cordova 6, make sure that this plugin is supported by the targeted CLI version.
Starting from Cordova 6, VS will only allow or show you plugins that are supported by the targeted CLI version.
Hope this helps.
It has been updated from com.ionic.keyboard to ionic-plugin-keyboard, just update it in you package.json file.
I ended up having the same problem.
I'm running on windows and updated to cordova 6.0.0 and ionic 1.7.14
I got the error initially but then ran Node.js as Administrator and then the commands worked, see screen examples;
Like most things this solution may not be for everyone but I guess no doubt I wont be alone with this issue.
Cheers
state has been removed from CLI v3. So on cordova 7 you need to run:
ionic cordova prepare
Related
Okay, so you run this. And it continues to fail.
cordova platform add android --save
And the output is this.
Error: Failed to fetch platform cordova-android#0.0.8
After trying to reinstall cordova, node, and other packages, I have had no luck. I am running this with the ionic blank starter package with ionic Cli 3.
For some reason with the latest version of everything, ionic, angular, the cli, etc, the platform was trying to add
cordova-android#0.0.8
To fix this, just go to this link and get the latest version, and run this...
sudo ionic cordova platform add android#6.4.0
I had the same issue and followed this link
https://github.com/apache/cordova-android/releases
There, I found that the latest version is 7.1.1
I tried this ionic cordova platform add android#7.1.1 but got the same error
From a forum I follow, I got this link https://www.npmjs.com/package/cordova-android
Then I tried this ionic cordova platform add android#7.1.0 and it ran as I expected
remove old android
ionic cordova platform rm android
add latest android
ionic cordova platform add android#latest
Every time I run ionic cordova build android and then ionic cordova emulate android, I get a version my app from maybe a month ago. Here's what I've tried:
I've deleted files including deleting them from /platforms/android to no effect.
I've tried updating my version number in my config.xml file.
I've tried deleting the APK and various other files from /build/android
I tried creating a new ionic app with ionic start and then after cding into the new directory for my new project and running the same two commands, I got the old version of my other app.
I've tried removing and then adding back cordova android with both the commands ionic cordova rm/add platform android and cordova rm/add platform android and these cause some bizarre responses. With the ionic prefix, the remove command works fine but on add, I get this:
...
C:\Users\max\Documents\omsLibrary>ionic cordova platform add android
cordova platform add android --save
√ Running command - done!
ionic cordova resources android --force
√ Collecting resource configuration and source images - done!
Platform android not detected. Would you like to install it? (Y/n)
Update: after globally installing cordova, I no longer get the above on add. I just get this:
cordova platform add android --save
× Running command - failed!
[WARN] Platform already added. Saving platforms to config.xml.
> cordova platform save
√ Running command - done!
[ERROR] No platforms detected. Please run: ionic cordova platform add
I can keep doing this forever if I want but it will keep giving me the same circular instructions.
I have no problems at all with ionic serve.
Here is what I get from ionic info (updated after following Suraj Rao's suggestion):
cli packages: (C:\Users\max\Documents\omsLibrary\node_modules)
#ionic/cli-utils : 1.13.1
ionic (Ionic CLI) : 3.13.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
#ionic/app-scripts : 1.3.7
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.7.1
System:
Android SDK Tools : 26.1.1
Node : v6.9.2
npm : 5.4.2
OS : Windows 10
Misc:
backend : pro
Here's what I get from the cordova ls command:
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-inapppurchase 1.1.0 "In App Purchase"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
What is the deal here? Do I just wipe and reinstall everything related to ionic and cordova? Thanks to anyone who can provide assistance!
Your app is updating background from your ionic dashboard.
So you can delete app from dashboard:
1. Go to your ionic dashboard
https://dashboard.ionicframework.com
2. Delete app
or you can remove update plugin (cordova-plugin-ionic):
3. Open terminal and
cd your_project_folder
4. Uninstall cordova-plugin-ionic
cordova plugin remove cordova-plugin-ionic
or both.
cordova (Cordova CLI) : not installed
You need to install cordova globally along with ionic cli.
Do:
npm i cordova -g
I finally figured this one out. Apparently, when I was first starting the project and I didn’t know what I was doing (not that I really know what I’m doing now!), I copied the contents of my project folder (max/documents/myapp) into its parent folder (max/documents) because I was making some change that I was worried would break things. I completely forgot I had done this. When I deleted all those files from my documents folder, it worked!
So what I think was happening was the different mechanisms in the build process used different logic to determine where the project and platforms folders are.The add platform command was adding the platform to its right location, but the find platform command was looking I suppose in /max rather than /max/documents for the platforms folder and failing to find it. Then the copy project files to build folder command was finding the correct destination but looking in /documents rather than /documents/myapp to find the files to be copied over to /max/documents/platforms/android and finding the code from my ancient version of the app.
I'm the development of cordova plugin in android.
Updating the javascript of Cordova plugin are not updated.
change:"./test/plugins/cordova-plugin-whitelist/whitelist.js"
cordova build android
Expect the update:/test/platforms/android/assets/www/plugins/cordova-plugin-whitelist/whitelist.js
In the version up of cordova it seems behavior has changed.
5.3.3-: OK
5.4.1+: NG
Thank you,
Instead of updating the plugin, I've found that I can remove it and re-add it. In my case, I'm referencing the plugin source code locally, via the --link option:
cordova plugin rm plugin-name
cordova plugin add custom-plugins/plugin-name --link
To make sure the correct version number is reflected in the newly added plugin, you can use:
cordova plugin ls
Run The below command
cordova plugin update plugin-name
I am no longer able to build my app and generate an apk anymore because an error shows up. Here is what happens when I try to build the app in the command prompt: Command Prompt
Can somebody please help me with this? Oh and this is what happens if I type ionic info in the command prompt:
Your environment has been set up for using Node.js 0.12.4 (x64) and npm.
C:\Users\Singh>ionic info
Your system information:
Cordova CLI: 5.1.1
Ionic CLI Version: 1.6.1
Ionic App Lib Version: 0.3.3
OS: Windows 7 SP1
Node Version: v0.12.4
C:\Users\Singh>
Try to remove the platform, and then add it again, and then build your application.
So, if you have android as targeted platform execute these commands:
ionic platform remove android
ionic platform add android
ionic build android
My son had a very similar problem, and we never did figure out what caused it. He ended up creating a brand new blank ionic project, and then just copying the www folder from the old project. It worked, and he was able to get things building again. If you try it, you'll also have to re-add your plugins, copy package.json and bower.json, and then rerun bower install and npm install. It's not pleasant, but it might be worth a shot if you're desperate.
I am trying to check for an established network connection through the phonegap/cordova API, but alas, it is not working.
I added the plugin as explained on the cordova documentation, and phonegap local plugin list gives [phonegap] org.apache.cordova.network-information.
However, simply calling
document.addEventListener("deviceready", function () {
alert(Object.keys(navigator.connection));
}, false);
results on my phone (Android 4.0.4) always returning 0 and running on an emulator with Android 4.4.2 logs into LogCat that navigator.connection is undefined. In fact, on both machines alert(Object.keys(navigator)); never shows the connection key.
Any solution?
Phonegap with Cordova 3.3.0
When you install the plugin it copies files to www/plugins and updates android.json
then when you build the project, the build copies the java to platforms/android/src/... and the js files to platforms\android\assets\www\plugins (and does any customisation defined in plugin.xml)
At multiple occasions I saw android.json not correctly updated and javascript files not copied. Removing and re-installing plugins solved the problem for me.
If you did not perform manual customisations to the platforms/android folder, I think the easiest way to clean your project would be to empty the /plugins folder and the platforms folder and then re-install all the plugins you need.
I had the same issue and found I had to run "cordova build" and then the status was returned correctly.
BEWARE
When I run cordova build, it appears to take everything in my ~/app/www directory and overried everything in app/platforms/android/assets/www/
My "install process" is as follows:
cordova create app com.app "App"
cd app
cordova platform add android
cordova plugin add org.apache.cordova.network-information
cordova plugin add org.apache.cordova.camera
cordova plugin add org.apache.cordova.geolocation
cordova build
I can then do code changes in app/www and when happy, 'deploy' it using 'cordova build' (which seems to always copy the files to app/platforms/android/assets/www/.
If I add another plugin using: (for example)
cordova plugin add org.apache.cordova.file
then I need to run
cordova build
to have it work.
I hope this helps
(I am using cordova 3.3.1-0.1.2 )