tkyaji / cordova-plugin-crypt-file

This plugin to encrypt the source files.
Apache License 2.0
178 stars 116 forks source link

requireCordovaModule issue with cordova 9 #78

Open mstrop opened 5 years ago

mstrop commented 5 years ago

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?

vccrespo commented 5 years ago

same problem here!

flastowizka commented 5 years ago

the same problem

PeterHdd commented 5 years ago

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
cyborgk9 commented 5 years ago

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 ...?).

PeterHdd commented 5 years ago

@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.

cyborgk9 commented 5 years ago

@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...)

jay34fr commented 5 years ago

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.

tomavic commented 4 years ago

you can use cordova 8 instead of 9

premathunga commented 3 years ago

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.