IBM Worklight 6.1 JsonStore issue on Android 4.4 - ibm-mobilefirst

I have upgraded to Worklight 6.1 & I was with expectation that the issue I mentioned here IBM Worklight Android 4.4 issue, JSON Store stopped working would be resolved and my app should work fine now. But still facing the JSONStore initialization issue in Android 4.4. Please check below log.
12-10 14:58:30.630: D/dalvikvm(14826): No JNI_OnLoad found in /data/app-lib/com.Test-2/libsqlcipher_android.so 0x41e371b0, skipping init
12-10 14:58:30.630: D/dalvikvm(14826): Trying to load lib /data/app-lib/com.Test-2/libdatabase_sqlcipher.so 0x41e371b0
12-10 14:58:30.630: W/linker(14826): libdatabase_sqlcipher.so has text relocations. This is wasting memory and is a security risk. Please fix.
12-10 14:58:30.630: E/dalvikvm(14826): dlopen("/data/app-lib/com.Test-2/libdatabase_sqlcipher.so") failed: dlopen failed: cannot locate symbol "_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj" referenced by "libdatabase_sqlcipher.so"...
12-10 14:58:30.640: E/jsonstore-core(14826): Error during provision
12-10 14:58:30.640: E/jsonstore-core(14826): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj" referenced by "libdatabase_sqlcipher.so"...
12-10 14:58:30.640: E/jsonstore-core(14826): at java.lang.Runtime.loadLibrary(Runtime.java:364)
12-10 14:58:30.640: E/jsonstore-core(14826): at java.lang.System.loadLibrary(System.java:526)
12-10 14:58:30.640: E/jsonstore-core(14826): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:144)
12-10 14:58:30.640: E/jsonstore-core(14826): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:137)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.jsonstore.database.DatabaseManager.openDatabaseIfNecessary(DatabaseManager.java:173)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.jsonstore.database.DatabaseManager.checkDatabaseAgainstSchema(DatabaseManager.java:87)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.plugin.storage.ProvisionActionDispatcher.isSchemaMismatched(ProvisionActionDispatcher.java:155)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.plugin.storage.ProvisionActionDispatcher.dispatch(ProvisionActionDispatcher.java:293)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.plugin.storage.BaseActionDispatcher.dispatch(BaseActionDispatcher.java:87)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.plugin.storage.DispatchingPlugin$ActionDispatcherRunnable.run(DispatchingPlugin.java:113)
12-10 14:58:30.640: E/jsonstore-core(14826): at com.worklight.androidgap.plugin.storage.DispatchingPlugin$SerialExecutor$1.run(DispatchingPlugin.java:147)
12-10 14:58:30.640: E/jsonstore-core(14826): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
12-10 14:58:30.640: E/jsonstore-core(14826): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
12-10 14:58:30.640: E/jsonstore-core(14826): at java.lang.Thread.run(Thread.java:841)
12-10 14:58:30.650: E/Test(14826): init notification error:----->{
12-10 14:58:30.650: E/Test(14826): "src": "initCollection",
12-10 14:58:30.650: E/Test(14826): "err": -1,
12-10 14:58:30.650: E/Test(14826): "msg": "PERSISTENT_STORE_FAILURE",
12-10 14:58:30.650: E/Test(14826): "col": "Notification",
12-10 14:58:30.650: E/Test(14826): "usr": "TestUser",
12-10 14:58:30.650: E/Test(14826): "doc": {},
12-10 14:58:30.650: E/Test(14826): "res": {}
12-10 14:58:30.650: E/Test(14826): }
12-10 14:58:30.660: E/Test(14826): [wl.jsonstore] {"src":"initCollection","err":-1,"msg":"PERSISTENT_STORE_FAILURE","col":"Notification","usr":"TestUser","doc":{},"res":{}}

Try the following:
Uninstall the application (just to make sure nothing is being cached)
Go to the application-descriptor.xml
Remove the JSONStore optional feature
Build
Make sure armeabi/libdatabase_sqlite.so, x86/libdatabase_sqlcipher.so and sqlcipher.jar are removed from the native folder under your Android environment. See the picture below under Files you care about.
Go to application-descriptor.xml
Enable the JSONStore optional feature
Build
Make sure armeabi/libdatabase_sqlite.so, x86/libdatabase_sqlcipher.so and sqlcipher.jar are back. Look at the FYI section for more details.
Refresh the native Android project on Eclipse.
Run on an emulator or device.
FYI
The size and MD5 hashes on my machine (Mac OSX 10.9) for the working libraries. Size was determined with ls -al and the MD5 hash was generated with md5 [file].
sqlcipher.jar
Size: 103300
MD5 Hash: 8d7f4d682994158096763c24e3d79fb2
armeabi/libdatabase_sqlite.so
Size: 365644
MD5 Hash: 07c4cf69d038c3fdcc7dd0490841ea3d
x86/libdatabase_sqlcipher.so
Size: 367020
MD5 Hash: 38756d70d256f8e5982ed9789705457f
The files you care about:
Still not working?
Create a new Worklight Project with v6.1 (won't work with other versions).
Create a new Hybrid Application.
Create an Android environments.
Go to the application-descriptor.xml
Enable JSONStore.
Build.
Confirm JSONStore works there.
Here's a quick example:
var collections = {
customers : {
searchFields : {
'CUSTOMERCODE' : 'string'
}
}
};
WL.JSONStore.init(collections)
.then(function () {
return WL.JSONStore.get('customers').add({'CUSTOMERCODE' : '456'});
})
.then(function () {
return WL.JSONStore.get('customers').findAll();
})
.then(function (res) {
alert(JSON.stringify(res));
})
.fail(function (err) {
alert(err.toString());
});
});
Copy armeabi/libdatabase_sqlite.so, x86/libdatabase_sqlcipher.so and sqlcipher.jar from that newly created project that works in Android v4.4 to your existing project. Make sure you build, uninstall a previous version of the app and refresh the native project before you send it to the device or emulator.

I'm was running an out-dated version of the lib. Using 2.2.2 works on 4.4 for me.
Download from here

Related

Error on Expo React Native trying to start on web, how can i fix it?

Basically, when I create a new expo project and use npm run web it throws me this error and I can't find the solution, please help, thanks
it does works to open it with android, the problem is only running on web
Logs for your project will appear below. Press Ctrl+C to exit.
node:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (X:\DataYProgramas\ReactJS\expo4\openty\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (X:\DataYProgramas\ReactJS\expo4\openty\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (X:\DataYProgramas\ReactJS\expo4\openty\node_modules\webpack\lib\NormalModule.js:471:10)
at X:\DataYProgramas\ReactJS\expo4\openty\node_modules\webpack\lib\NormalModule.js:503:5
at X:\DataYProgramas\ReactJS\expo4\openty\node_modules\webpack\lib\NormalModule.js:358:12
at X:\DataYProgramas\ReactJS\expo4\openty\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (X:\DataYProgramas\ReactJS\expo4\openty\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (X:\DataYProgramas\ReactJS\expo4\openty\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (X:\DataYProgramas\ReactJS\expo4\openty\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at X:\DataYProgramas\ReactJS\expo4\openty\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at X:\DataYProgramas\ReactJS\expo4\openty\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.12.1
Which version of node.js you using, because for me is not working on latest(18.12.1) but working on 16.18.1, but on version 16.18.1 not working on ios

Expo React Native Can't find variable: TextDecoder

So for some reason i'm having this bug when i try to run the app on the Expo Go app in my phone. Apparently is ok if i run on the web browser.
This is the error log
ReferenceError: Can't find variable: TextDecoder
Stack trace:
node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in
error
node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in
reportException
node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19
in handleException
node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in
handleError
node_modules#react-native\polyfills\error-guard.js:49:36 in
ErrorUtils.reportFatalError
node_modules\metro-runtime\src\polyfills\require.js:203:6 in
guardedLoadModule
http://192.168.0.29:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:190345:3
in global code ...
This happened to us too, on an app that had used to work in an older Expo version. The solution for us was to add this line to our .babelrc.js file:
"presets": [
["babel-preset-expo", {
lazyImports: true, // <<< The fix
]
]
Got over the problem by doing this;
npm install text-encoding
npm install big-integer
and pasting this code inside node_modules>react-native>Libraries>LogBox
const TextEncodingPolyfill = require('text-encoding');
const BigInt = require('big-integer')
Object.assign(global, {
TextEncoder: TextEncodingPolyfill.TextEncoder,
TextDecoder: TextEncodingPolyfill.TextDecoder,
BigInt: BigInt,
});

Exception in native call from JS: Unexpected token '<'

Installing an existing React-native application is throwing error.
Logcat error:
E/unknown:ReactNative: Exception in native call from JS
com.facebook.react.devsupport.JSException: Unexpected token '<'
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:920)
Caused by: com.facebook.jni.CppException: Unexpected token '<'`
no stack
... 8 more
D/SoLoader: Loaded: libyoga.so
E/ReactNativeJNI: Attempting to call JS function on a bad application bundle: HMRClient.setup()
E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Attempting to call JS function on a bad application bundle: HMRClient.setup()
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:920)
E/ReactNativeJNI: Attempting to call JS function on a bad application bundle: AppRegistry.runApplication()
E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Attempting to call JS function on a bad application bundle: AppRegistry.runApplication()
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:920)
D/SoLoader: init exiting
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.4
CPU: (8) x64 Apple M1
Memory: 40.87 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.19.0 - /usr/local/bin/node
npm: 6.14.16 - /usr/local/bin/npm
Watchman: 2022.06.13.00 - /opt/homebrew/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
Android SDK:
API Levels: 29, 30, 31, 32
Build Tools: 29.0.2, 30.0.2, 30.0.3, 32.0.0, 32.1.0
System Images: android-30 | Intel x86 Atom_64, android-32 | Google APIs ARM 64 v8a
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8193401
Xcode: 13.0/13A233 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.1 => 0.61.1
Steps to reproduce
Create a React native app with version 0.61.1,
Install npm dependencies: npm i (tried npm i --legacy-peer-deps)
Run metro server: npx react-native start --reset-cache
Run android build: npx react-native run-android (I am using Android studio to run the app)
I have already been through following issue resolutions but nothing worked for me:
https://github.com/facebook/react-native/issues/21074
https://github.com/facebook/react-native/issues/32875
https://github.com/babel/babel/issues/14139
First clear your cache and node_module using the below command
cd android && ./gradlew cleanBuildCache && cd .. &&
watchman watch-del-all && rm -rf node_modules/ &&
rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf
$TMPDIR/metro-bundler-cache-* &&
yarn cache clean && yarn install &&
yarn start --reset-cache
After done this change you babel.config.js
module.exports = {
presets: [['module:metro-react-native-babel-preset', {
unstable_disableES6Transforms: true
}]],
};

Android app crash with error 'com.facebook.jni.CppException : Can't find variable: setTimeout' android 64 bit APK with React native 0.59.10

App crashing on launch with setTimeOut error
I have created project using create-react-native-web command & upgraded 0.55.x to 0.59.10 for android 64 bit support using https://react-native-community.github.io/upgrade-helper/?from=0.55.3&to=0.59.10
We are facing below error on launching app crash -
Error in details -
com.facebook.jni.CppException: Can't find variable: setTimeout
index.android.bundle:206:7357
h#index.android.bundle:2:1670
index.android.bundle:205:53
h#index.android.bundle:2:1670
index.android.bundle:204:92
h#index.android.bundle:2:1670
index.android.bundle:13:2046
h#index.android.bundle:2:1670
index.android.bundle:11:46
h#index.android.bundle:2:1670
d#index.android.bundle:2:868
global code#index.android.bundle:304:4
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:2

eslint not working in Atom for react native project

linter and linter-eslint modules are installed in Atom
Create a react native project
react-native init AwesomeApp
Install requisite node modules
yarn add babel-eslint eslint-config-airbnb-base eslint-plugin-react eslint-plugin-react-native --dev
Create .eslintrc file:
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"extends" : [
"eslint:recommended",
"plugin:react/recommended",
"airbnb-base"
],
"rules" : {
"arrow-body-style" : 'warn'
}
}
When I open Atom I get an error
Here is the stack trace from the dev tools:
/Volumes/Macintosh HD 3/.atom/packages/linter/lib/linter-registry.js:159 [Linter] Error running ESLint Error: Failed to load plugin react-native: Cannot find module 'eslint-plugin-react-native'
at Function.Module._resolveFilename (module.js:455:15)
at Function.resolve (internal/module.js:27:19)
at Object.load (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config/plugins.js:134:29)
at Array.forEach (native)
at Object.loadAll (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config/plugins.js:162:21)
at Object.load (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config/config-file.js:541:21)
at loadConfig (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config.js:63:33)
at new Config (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/config.js:229:42)
at CLIEngine.executeOnText (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/node_modules/eslint/lib/cli-engine.js:741:28)
at lintJob (/Volumes/Macintosh HD 3/.atom/packages/linter-eslint/lib/worker.js:50:51)
Atom is up to date, I'm running 1.18.0 x64
eslint-plugin-react-native is definitely installed within the project. Any ideas what I'm missing?
For me, removing this line worked:
"parser": "babel-eslint",