I am trying to add android platform to my existing ionic project. I am getting the below error.
Failed to restore plugin com.couchbase.lite.phonegap from config.xml. You might need to try adding it again.
Error:
Error: npm: Command failed with exit code 1 Error output:
I guess you tried on Android >= 7 which is needed for the couchbaselite plugin.
so you can downgrade to 6 :
ionic cordova platform rm android
ionic cordova platform add android#6
But if you need a recent android, you have to apply this Fixes : https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin/pull/110
remove manually node-modules and package-lock.json (imp*)
npm cache clean --force
finally run npm install
ionic cordova platform add android
I suggest you to remove the plugin and it's folder:
ionic cordova plugin remove couchbase-lite-phonegap-plugin
rm -rf plugins/com.couchbase.lite.phonegap/
Also, remove any line in package.json using the wrong folder name of com.couchbase.lite.phonegap, if you find any.
Then add your android platform as usual, then add the plugin back.
ionic cordova platform add android
ionic cordova plugin add couchbase-lite-phonegap-plugin
And if you still get any error, repeat the operation using the cordova --verbose directly, without ionic command. Example:
cordova plugin add couchbase-lite-phonegap-plugin --verbose
That command above should tell you exactly what went wrong.
Related
I get an error while building with cordova.
Error: Source and destination must not be the same.
Build-System:
Ionic:
ionic (cli): 4.10.1
ionic framework: ionic-angular 3.9.2
#ionic/app-scripts: 3.1.11
Cordova:
cordova (cli): 8.1.2 (cordova-lib#8.1.1)
platforms: "cordova-android": "8.0.0"
System:
Android SDK Tools: 26.1.1
NodeJS: 10.15.3
npm: 6.4.1
OS: Windows 10
Command:
ionic cordova build android
or
cordova build --release
Error-Details:
Error: Source and destination must not be the same.
at checkPaths (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\fs-extra\lib\copy-sync\copy-sync.js:185:11)
at Object.copySync (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\fs-extra\lib\copy-sync\copy-sync.js:25:20)
at updatePathWithStats (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:103:24)
at C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:298:19
at Array.forEach (<anonymous>)
at Object.mergeAndUpdateDir (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:296:33)
at updateWww (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\lib\prepare.js:157:17)
at Api.module.exports.prepare (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\lib\prepare.js:56:19)
at Api.prepare (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\Api.js:177:45)
at C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:105:36
Does anyone facing the same error or has an idea what's wrong?
Additional infos:
I always check out the git repository to a empty folder. This means: It's a hard-clean every build. No node_modules and no platform, etc. (rm platform etc. is useless)
I don't know if this is the correct answer, but it could be a wrong setting in the cordova build.json (if you have one).
Since you are using Jenkins, maybe you have some wrong settings there like missing dependencies or something like that.
You can also try to remove the platform and add it again to get the latest version and compatibility.
cordova platform remove android
cordova platform add android#8.0.0
You can check if you have an outdated fs-extra (although I don't think that is the problem) and update Ionic.
You can try to restore your node_modules.
I hope one of these steps help.
At first, manually remove this:
node_modules folder
package-lock.json file
platform > android folder
then use this commend:
1 => npm rm -rf node_modules package-lock.json
2 => npm cache clear --force
3 => ionic cordova platform add android#8.0.0
4 => ionic cordova prepare android
5 => ionic cordova run android
The problem is fs-extra checkPaths method of copy operation. There is a check of state.ino (inode) of node fs which is evaluated as number. Bigint is also supported but not enabled. This is the reason that the comparsion can fail. Because max-safe-integer in JavaScript is 53-bit. Maybe also a symlink issue.
See / Join:
https://github.com/jprichardson/node-fs-extra/issues/657
Why Cordova-Android 8.0.0?
Because https://github.com/apache/cordova-common/blob/master/RELEASENOTES.md . fs-extra is new in this version.
In my case it happened while removing/adding android again to make sure that some plugins are updated.
This solution fixed my issue as referenced here
cordova clean android
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
When a try to run
ionic run android --device
I'm getting an error of module:
Error: Cannot find module 'android-versions'
Versions:
java -version
java version "1.8.0_144"
Android studio Version 2.3.3
ionic -v
2.2.1
cordova -v
6.5.0
I found the problem and expect help somebody.
I just run
npm install android-versions --save
in the project folder and worked.
Not sure if this will help some other Ionic developers, but I was getting the same Error: Cannot find module 'android-versions' and I fixed it by removing and adding the Android platform again:
ionic cordova platform remove android --save
And then
ionic cordova platform add android --save
If anyone is having this issue while using yarn and even after adding android-versions... it seems that there are differences in yarn/npm files which break...
I ended up removing my node_modules folder, then installing it with npm instead of yarn. It worked!
I'm trying to install a Cordova Plugin with Cordova CLI 7.
This plugin does not have a package.json file on it, so it throws an error when adding it to my project.
I've tried converting the config.xml file using plugman. And it works fine for Android but it doesn't for iOS. I feel like I'm missing some configuration from the config.xml in my package.json file.
Is there a way to safely convert the config.xml in a package.json file? or a way to install it using the config.xml file?
Thanks
Yes, since Cordova 7, the installation of platforms and plugins are by default performed using cordova-fetch which in turn uses npm install to add/remove modules. Therefore a package.json is required by default. But you should be able to add plugins lacking a package.json file by using the nofetch parameter, which forces Cordova to use the old method instead, please note that this parameter has been removed in cordova 8.0.0:
cordova plugin add cordova-plugin-camera --nofetch
For me when adding a custom plugin like so
cordova plugin add .\custom-plugins\my-plugin --nofetch
This does not work on MAC for me for some reason.
I resort to building it all for Android then copy over all the files, except node_modules and platforms, then do a 'cordova build ios' it seems to build fine with the custom plugins included. Not the best way i know, but once the plugin is added i can move on and continue. If you get it to work please share.
--nofetch option is removed in Cordova 8.0.0: https://issues.apache.org/jira/browse/CB-13055
If you have already installed Cordova 8.x.x then you can downgrade it to version 7.1.0 and then use the --nofetch option.
Run the following command to downgrade Cordova to 7.1.0:
npm install -g cordova#7.1.0
If the above command doesn't work, then try uninstalling cordova at first and then install cordova version 7.1.0:
npm uninstall -g cordova
npm install -g cordova#7.1.0
Then, check the Cordova version:
cordova --version
So I wanted to start a new ionic project by writing:
ionic start Ionic1 blank
After that I moved to that new directory and wanted to add android platform:
ionic platform add android
I then got this error:
Error: Failed to fetch platform android
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES: permission denied, open '/home/think/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore'
I don't know why this happens. I tried these:
1) change the permision with
chmod 744 /home/think/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore
2) uninstalled and installed nodejs, cordova, ionic, etc.
3) Executed with sudo ionic platform add android (but "sudo" is not necessary i think since I added android platform before in other projects without having to write "sudo" )
Still it's somehow not possible to add a platform.
I'm on ubuntu 14.04 LTS. I have android SDK manager installed.
I can build and run my other ionic projects that I created earlier. But since yesterday I can't build new projects anymore. It happened when I iupdated to ionic 1.7.13. I tried to downgrade ionic to an earlier version but that wouldn't solve the issue either.
Maybe this is a cache problem of cordova. Delete the cache and try to add the platform again:
rm -rf ~/.cordova
I have no idea what went wrong. i just installed cordova and ionic again and now it's working. For those who encountered the same problem: The commands I executed:
sudo npm install -g cordova
sudo npm install -g ionic
After that add, build, and run the project just as usual.
Try adding it with cordova instead of ionic.
cordova platform add android