0

How can I include the necessary '.so' files into the Android environment of a Worklight project so that this plugin works effectively?

Plugin github: https://github.com/litehelpers/Cordova-sqlcipher-adapter

General Info:

  • Worklight version: 6.2.0.01-20141216-0427
  • This is a hybrid worklight project

I want to utilize this sqlcipher cordova plugin to store and encrypt data locally on the device. I want to use this rather than JSONstore so I can reuse existing application js code for a websql db but now have it encrypt the data (this plugin uses same API).

What I have done so far:

I have attempted two approaches for the Android environment: 1. External Android Library Project:

  **Outcome** -- Despite pulling this library into my project and trying all of the solutions at this link: https://stackoverflow.com/questions/7870265/unable-to-execute-dex-multiple-dex-files-define-lcom-myapp-rarray I cannot get past this error:

`[2011-10-23 16:23:29 - Dex Loader] Unable to execute dex: Multiple dex files define Lnet/sqlcipher/R$drawable;

[2011-10-23 16:23:29 - myProj] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lnet/sqlcipher/R$drawable;`

  1. Adding the .jar directly to the Android Worklight environment: I have succesfully added the sqlcipher.jar to the Android project via 'Configure Build Path...' --> 'Add jar'. But I the plugin is not working effectively -- which makes sense because I cannot get the '.so' files loaded into the project

    I have tried including them in the Android/nativeResources folder as libs/armeabi, libs/armeabi-v7a, and libs/x86 which should override the corresponding folders in the native/libs folder according to this link: Adding native code to an existing Worklight hybrid app

    How can I get these files loaded in?

Any help will be much appreciated! I'm a new user so I can't upload photos yet, sorry! I will update with photos as soon as I can.

Community
  • 1
  • 1
Kellen Busby
  • 531
  • 4
  • 10
  • Too much superfluous text. Start with the basics please: What is your Worklight version and build number? Is this a Native project or a Hybrid project? SQLCipher is provided internally as part the JSONStore feature, so why are you trying to add it? What are you trying to accomplish and why are you trying to do it that way? Answer all questions. – Idan Adar Sep 25 '15 at 17:46
  • Updated above in General Info section. Sorry for being long-winded. – Kellen Busby Sep 25 '15 at 18:08
  • It will not be easy or possible to overcome the multiple dex files error in 6.2. I do suggest to find a mix between adding the jsonstore feature, which adds sqlcipher, and using the existing code that you have. Perhaps that is suffice. Maybe even just add the feature but any files you do Not need, leaving the ones you Do need. – Idan Adar Sep 25 '15 at 18:12
  • Thanks for recommendation - trying now... Is there any easy way to replace the sqlcipher.jar in the libs folder with the sqlcipher.jar from the plugin? I tried this once and when I loaded my app I received an error: could not load: "android_asset/www/skinLoader.html" and app won't launch – Kellen Busby Sep 25 '15 at 19:07
  • Why is it needed to replace the .jar file? Using the existing one does not work with the code you already have? – Idan Adar Sep 26 '15 at 05:12
  • Yes, the included sqlcipher.jar is missing a few custom methods compared to the sqlcipher.jar version included with the plugin. – Kellen Busby Sep 27 '15 at 19:33

1 Answers1

0

Unfortunately, JSONStore is coupled with the sqlcipher 2.1 in 6.2 so you can the removal of this jar file is not trivial. This will be solved in the next version of Worklight (7.2). I would suggest not including JSONStore in your hybrid so that you can utilize the Cordova plugin that uses a different version of sqlcipher.

Namfo
  • 301
  • 2
  • 8
  • Do you have a solution to including the necessary sqlcipher.jar (Cordova plugin version) and '.so' files into the Android project? I can't seem to get them included without running into an error. – Kellen Busby Sep 27 '15 at 19:32
  • I am not sure what the so file is but you can use System.load to load any library file. Since JSONStore relies on sqlcipher 2.1 and you need to use custom sqlcipher.jar for the cordova plugin you will need to remove JSONStore from your app and then add your jar file to the libs folder. – Namfo Sep 27 '15 at 20:09
  • I need to add sqlcipher.jar and three .so libraries for each architecture (i.e. armeabi | armeabi-v7a | etc.) but whenever I add them to my libs folder in the android folder of my Worklight project they do not build to the generated Android project. So I've been trying things like adding them to the build path but I get an error like this: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libsqlcipher_android.so" – Kellen Busby Sep 27 '15 at 21:01
  • The only reason why I think you would be getting this error is because you are still trying to use JSONStore in your app. When you enable the JSONStore optional feature it will generate 4 .so files after building the app [JSONStore so files](http://i641.photobucket.com/albums/uu140/Hayata_Shin/Screen%20Shot%202015-09-27%20at%204.08.14%20PM_zpseddtqrup.png) Could you provide your project structure in your libs folder? – Namfo Sep 27 '15 at 21:10
  • Can't upload photos but here's a link: https://flic.kr/p/ySVFBH This is without the necessary files loaded in because I just tried to add them to the libs and lib/[architecture] folders in the generated android project and then adding them to the build path. When I built the android environment, those files got deleted – Kellen Busby Sep 27 '15 at 21:23
  • I think I know why they're getting removed: http://www-01.ibm.com/support/docview.wss?uid=swg1PI10227 Looks like they automatically get removed if JSONstore is not enabled (since they are the same file names). Trying to figure out how to rename them now. – Kellen Busby Sep 27 '15 at 23:34