Ionic - Error: Cannot find module 'android-versions' - android

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!

Related

Error: unknown flag `p' when trying to run ionic cordova run android

I have an ionic cordova project in which i tried to run with ionic cordova run android (sometimes with sudo too) and it returns me this error: error: unknown flag p' and /usr/bin/snap: Command failed with exit code 64.
I have tried reinstalling node, npm, ionic and cordova but it hasn't worked out for me :/
I also have removed platforms, removed plugins, node_modules but no luck also.
When i do a ionic cordova prepare android, the script runs perfectly but i get this error when i try to run or emulate it
My node version is v10.24.0, npm version 6.14.11, ionic 5.4.12 and cordova 10.0.0
I have finnaly solved it by uninstalling gradle and then installing it again on version 5.6.3

Unable to add android project - ionic( Error - com.couchbase.lite.phonegap)

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.

fs-extra: source and destination must not be the same. (cordova)

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

ionic1 Error: gfs.gracefulify is not a function

i am trying this command sudo ionic platform add android it shows me below error.
Error: gfs.gracefulify is not a function
My versoin
Cordova CLI: 6.4.0
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Node Version: v4.4.2
what happnes i dont know. pls help me. thanks in advance
This is most probably related to a quirk/bug in npm 3.x.
Try upgrading to the latest stable node 5.10.1 and reinstalling ionic
Goto
/usr/local/lib/node_modules/cordova/node_modules/
rename the npm-directory to something else.
Now, Cordova will use the global (and hopefully correct) npm.

Install Cordova plugin without package.json file on it

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

Categories

Resources