Question

Environment:

Worklight 6.1

Samsung Tab 3

Android 4.2.2

Code to initialize JSONStore -

var collections = {};
collections["SampleApp"] = {};
collections["SampleApp"].searchFields = {uName: 'string', uPassword: 'string'};

var options = {};
options.username = "offlineUser";
options.password = "psw12345";
options.localKeyGen = true;
options.clear = false;

WL.JSONStore.init(collections, options)
.then(function () {
    WL.Logger.debug("Successfully initialized JSON Store");
})
.fail(function (errorObject) {
    WL.Logger.debug("Error while initialing JSON Store - " + errorObject);
});

I am getting following exception while initializing JSONStore -

03-29 14:02:15.735: D/dalvikvm(18569): Trying to load lib /data/data/com.sample.mobile.SampleApp/files/libcrypto.so.1.0.0 0x424a8a20
03-29 14:02:15.740: D/dalvikvm(18569): Added shared lib /data/data/com.sample.mobile.SampleApp/files/libcrypto.so.1.0.0 0x424a8a20
03-29 14:02:15.740: D/dalvikvm(18569): No JNI_OnLoad found in /data/data/com.sample.mobile.SampleApp/files/libcrypto.so.1.0.0 0x424a8a20, skipping init
03-29 14:02:15.785: W/PluginManager(18569): THREAD WARNING: exec() call to StoragePlugin.isKeyGenRequired blocked the main thread for 45ms. Plugin should use CordovaInterface.getThreadPool().
03-29 14:02:15.855: I/dalvikvm(18569): Could not find method org.json.JSONException.<init>, referenced from method com.worklight.androidgap.jsonstore.security.DPKBean.<init>
03-29 14:02:15.855: W/dalvikvm(18569): VFY: unable to resolve direct method 24133: Lorg/json/JSONException;.<init> (Ljava/lang/Throwable;)V
03-29 14:02:15.855: D/dalvikvm(18569): VFY: replacing opcode 0x70 at 0x000d
03-29 14:02:16.830: D/dalvikvm(18569): Trying to load lib /data/app-lib/com.sample.mobile.SampleApp-1/libopenssl_fips.so 0x424a8a20
03-29 14:02:16.830: D/dalvikvm(18569): Added shared lib /data/app-lib/com.sample.mobile.SampleApp-1/libopenssl_fips.so 0x424a8a20
03-29 14:02:16.830: D/dalvikvm(18569): No JNI_OnLoad found in /data/app-lib/com.sample.mobile.SampleApp-1/libopenssl_fips.so 0x424a8a20, skipping init
03-29 14:02:16.830: I/dalvikvm(18569): Could not find method com.google.common.collect.Maps.newHashMap, referenced from method net.sqlcipher.database.SQLiteDatabase.<init>
03-29 14:02:16.830: W/dalvikvm(18569): VFY: unable to resolve static method 762: Lcom/google/common/collect/Maps;.newHashMap ()Ljava/util/HashMap;
03-29 14:02:16.830: D/dalvikvm(18569): VFY: replacing opcode 0x71 at 0x0024
03-29 14:02:16.845: D/dalvikvm(18569): Trying to load lib /data/app-lib/com.sample.mobile.SampleApp-1/libstlport_shared.so 0x424a8a20
03-29 14:02:16.845: D/dalvikvm(18569): Added shared lib /data/app-lib/com.sample.mobile.SampleApp-1/libstlport_shared.so 0x424a8a20
03-29 14:02:16.845: D/dalvikvm(18569): No JNI_OnLoad found in /data/app-lib/com.sample.mobile.SampleApp-1/libstlport_shared.so 0x424a8a20, skipping init
03-29 14:02:16.845: D/dalvikvm(18569): Trying to load lib /data/app-lib/com.sample.mobile.SampleApp-1/libsqlcipher_android.so 0x424a8a20
03-29 14:02:16.850: D/dalvikvm(18569): Added shared lib /data/app-lib/com.sample.mobile.SampleApp-1/libsqlcipher_android.so 0x424a8a20
03-29 14:02:16.850: D/dalvikvm(18569): No JNI_OnLoad found in /data/app-lib/com.sample.mobile.SampleApp-1/libsqlcipher_android.so 0x424a8a20, skipping init
03-29 14:02:16.850: D/dalvikvm(18569): Trying to load lib /data/app-lib/com.sample.mobile.SampleApp-1/libdatabase_sqlcipher.so 0x424a8a20
03-29 14:02:16.850: D/dalvikvm(18569): Added shared lib /data/app-lib/com.sample.mobile.SampleApp-1/libdatabase_sqlcipher.so 0x424a8a20
03-29 14:02:16.850: I/Database(18569): JNI_OnLoad called
03-29 14:02:16.850: I/Database(18569): JNI_OnLoad register methods 
03-29 14:02:16.850: E/jsonstore-core(18569): Error during provision
03-29 14:02:16.850: E/jsonstore-core(18569): java.lang.NoClassDefFoundError: com.google.common.collect.Maps
03-29 14:02:16.850: E/jsonstore-core(18569):    at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:352)
03-29 14:02:16.850: E/jsonstore-core(18569):    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:900)
03-29 14:02:16.850: E/jsonstore-core(18569):    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:947)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.jsonstore.database.DatabaseManager.openDatabaseIfNecessary(DatabaseManager.java:185)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.jsonstore.database.DatabaseManager.checkDatabaseAgainstSchema(DatabaseManager.java:87)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.plugin.storage.ProvisionActionDispatcher.isSchemaMismatched(ProvisionActionDispatcher.java:155)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.plugin.storage.ProvisionActionDispatcher.dispatch(ProvisionActionDispatcher.java:293)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.plugin.storage.BaseActionDispatcher.dispatch(BaseActionDispatcher.java:87)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.plugin.storage.DispatchingPlugin$ActionDispatcherRunnable.run(DispatchingPlugin.java:113)
03-29 14:02:16.850: E/jsonstore-core(18569):    at com.worklight.androidgap.plugin.storage.DispatchingPlugin$SerialExecutor$1.run(DispatchingPlugin.java:147)
03-29 14:02:16.850: E/jsonstore-core(18569):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
03-29 14:02:16.850: E/jsonstore-core(18569):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
03-29 14:02:16.850: E/jsonstore-core(18569):    at java.lang.Thread.run(Thread.java:856)
03-29 14:02:16.865: D/SampleApp(18569): Error while initialing JSON Store - {
03-29 14:02:16.865: D/SampleApp(18569):  "src": "initCollection",
03-29 14:02:16.865: D/SampleApp(18569):  "err": -1,
03-29 14:02:16.865: D/SampleApp(18569):  "msg": "PERSISTENT_STORE_FAILURE",
03-29 14:02:16.865: D/SampleApp(18569):  "col": "SampleApp",
03-29 14:02:16.865: D/SampleApp(18569):  "usr": "offlineUser",
03-29 14:02:16.865: D/SampleApp(18569):  "doc": {},
03-29 14:02:16.865: D/SampleApp(18569):  "res": {}
03-29 14:02:16.865: D/SampleApp(18569): }
03-29 14:02:16.865: D/SampleApp(18569): loadServerConnectionDetails
03-29 14:02:16.885: E/SampleApp(18569): [wl.jsonstore] {"src":"initCollection","err":-1,"msg":"PERSISTENT_STORE_FAILURE","col":"SampleApp","usr":"offlineUser","doc":{},"res":{}}

Please let me know, if more data required from my side. Any help will be much appreciated.

Was it helpful?

Solution

The exception was occurring because of the missing guava.jar file on the build machine -

/apps/SampleApp/android/native/libs/guava.jar

which got generated after an upgrade from Worklight 6.0 to 6.1.

We have followed the worklight doc - Integrating with source control systems which doesn't mention anything about "libs" folder and hence didn't checked-in the file.

Now build machine takes whatever checked-in and builds the APK file. The generated APK file doesn't contain "guava.jar" file, which contains package "com.google.common.collect.Maps". And hence we were seeing the issue.

Note: We were seeing the issue after adding changes to use JSONStore. So it looks like JSONStore use this package.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top