cordova-plugin-crypt-file icon indicating copy to clipboard operation
cordova-plugin-crypt-file copied to clipboard

requireCordovaModule issue with cordova 9

Open mstrop opened this issue 5 years ago • 9 comments

After upgrading Cordova to version 9 I get this error message:

Using "requireCordovaModule" to load non-cordova module "path" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.

It's related to after_prepare.js file. Is there a way, how to fix this?

mstrop avatar Mar 24 '19 17:03 mstrop

same problem here!

vccrespo avatar Mar 24 '19 23:03 vccrespo

the same problem

flastowizka avatar Mar 27 '19 03:03 flastowizka

For anyone having issues with Cordova 9:

You can use the following plugin:

https://github.com/PeterHdd/cordova-plugin-crypto-file

I have updated it and now it works with Cordova 9.

to install it do the following:

npm i cordova-plugin-crypto-file@latest

PeterHdd avatar Apr 01 '19 10:04 PeterHdd

Thanks @PeterHdd. I wasn't able to use Ionic as it can't guarantee the layout will be the same on every device. Instead I'm using Crosswalk. I referenced Peter's version to get a file that worked still.

In hooks/after_prepare.js, I changed: var path = context.requireCordovaModule('path'), fs = context.requireCordovaModule('fs'), crypto = context.requireCordovaModule('crypto'), Q = context.requireCordovaModule('q'),

to: var path = require('path'), fs = require('fs'), crypto = require('crypto'), Q = require('q'),

And: var sourceFile = path.join(pluginDir, 'com/tkyaji/cordova/DecryptResource.java');

to: var sourceFile = path.join(pluginDir, '../app/src/main/java/com/tkyaji/cordova/DecryptResource.java');

(I'm not really sure why the path is different... but that seemed to fix it. Something about the different 'path' object I guess).

I hope that helps others until this plugin gets updated (Please, @tkyaji ...?).

cyborgk9 avatar Apr 17 '19 03:04 cyborgk9

@cyborgk9 you can just use the plugin I referenced, made it to work with the new ionic webview. But it can work even if you are not using ionic.

PeterHdd avatar Apr 17 '19 03:04 PeterHdd

@cyborgk9 you can just use the plugin I referenced, made it to work with the new ionic webview. But it can work even if you are not using ionic.

@PeterHdd Hmm; well, my app seemed to render incorrectly until I installed cordova-plugin-ionic-webview, but that bypassed Crosswalk I guess, as there were other layout issues. Maybe there's a way to get Ionic running with Crosswalk, in which case I would use that and your plugin... (that'd be ideal, in fact...)

cyborgk9 avatar Apr 17 '19 03:04 cyborgk9

Hi all,

Anyone find a solution for this plugin not working on Cordova 9 (not ionic) ?

I tried https://github.com/PeterHdd/cordova-plugin-crypto-file It works on build, files are crypted but are not decrypted after installation.

Thx in advance.

jay34fr avatar Jun 21 '19 08:06 jay34fr

you can use cordova 8 instead of 9

tomavic avatar Jan 03 '20 14:01 tomavic

platform : android 9 cordova : v.10.0.0

remove plugin cordova plugin rm cordova-plugin-crypt-file

install plugin cordova plugin add cordova-plugin-crypto-file@latest

latest version 1.4.0 fixes the cordova 9 issue.

premathunga avatar Jan 12 '21 17:01 premathunga