MobileFirst JSON 使用 Android Studio 在构建中存储初始化错误
MobileFirst JSON Store Init Error on builds w/ Android Studio
在使用 Android 构建 apk(android-debug.apk 或签名 android-release.apk 时无法初始化 JSON 存储工作室。当我使用 MFP CLI 模拟或使用 Cordova-debug.apk 时,相同的代码初始化 JSON 存储成功。
使用 MFP 7.1.0.00.20160217-1815
WL.JSONStore.init({test:{}}, {username:'abc',password:'abc'}).then(function (coll) {
console.log('Done',coll);
}).fail(function (error) {
console.log('Setup store error', error);
});
下面是抛出 INVALID_KEY_ON_PROVISION
错误的日志。这发生在应用程序的第一个 运行 上,所以我怀疑该错误是否与无效密码有关。如果没有提到集合,init 也会成功。
V/WindowManager( 1298): Adding window Window{1fe251eb u0 PopupWindow:ff4fcc1} at 3 of 6 (after Window{12c29fd0 u0 com.sample.app/com.sample.app.CordovaApp})
W/EGL_emulation( 5265): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 5265): Failed to set EGL_SWAP_BEHAVIOR on surface 0xe1d22080, error=EGL_SUCCESS
I/UsageStatsService( 1298): User[0] Flushing usage stats to disk
D/HttpPostRequestSender( 5265): WLHybridRequestSender.run in WLHybridRequestSender.java:42 :: Sending request http://192.168.1.124:10080/DemoRuntime/apps/services/random?bytes=32
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:553 :: os.arch: x86_64
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:574 :: Extracting zip file: featurelibs/x86/libcrypto.so.1.0.0
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:584 :: Loading library using System.load: /data/data/com.sample.app/files/libcrypto.so.1.0.0
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:589 :: com.mobileiron.wrapped is set to false
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:594 :: Loading library using System.load: /data/data/com.sample.app/files/libcrypto.so.1.0.0
E/JSONSTORE( 5265): JSONStoreLogger.logError in JSONStoreLogger.java:189 :: Error setting key
E/JSONSTORE( 5265): com.worklight.jsonstore.exceptions.JSONStoreInvalidPasswordException: Error setting key.
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.handleUsernameAndPassword(WLJSONStore.java:232)
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.provisionDatabase(WLJSONStore.java:148)
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.openCollections(WLJSONStore.java:347)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.ProvisionActionDispatcher.initializeCollection(ProvisionActionDispatcher.java:152)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.ProvisionActionDispatcher.databaseActionDispatch(ProvisionActionDispatcher.java:138)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.BaseDatabaseActionDispatcher.actionDispatch(BaseDatabaseActionDispatcher.java:36)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.BaseActionDispatcher.dispatch(BaseActionDispatcher.java:90)
E/JSONSTORE( 5265): at com.worklight.androidgap.plugin.DispatchingPlugin$ActionDispatcherRunnable.run(DispatchingPlugin.java:79)
E/JSONSTORE( 5265): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/JSONSTORE( 5265): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/JSONSTORE( 5265): at java.lang.Thread.run(Thread.java:818)
E/JSONSTORE( 5265): Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sample.app-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopenssl_fips.so"
E/JSONSTORE( 5265): at java.lang.Runtime.loadLibrary(Runtime.java:366)
E/JSONSTORE( 5265): at java.lang.System.loadLibrary(System.java:988)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.security.FipsWrapper.<clinit>(FipsWrapper.java:28)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.security.SecurityUtils.encrypt(SecurityUtils.java:68)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.security.SecurityManager.storeDPK(SecurityManager.java:99)
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.handleUsernameAndPassword(WLJSONStore.java:221)
E/JSONSTORE( 5265): ... 10 more
I/chromium( 5265): [INFO:CONSOLE(7)] "Setup store error", source: (7)
E/wl.jsonstore( 5265): {"src":"initCollection","err":-3,"msg":"INVALID_KEY_ON_PROVISION","col":"test","usr":"abc","doc":{},"res":{}}
作为解决方法,我已手动签署发布版本。这恰好有效,但 apk 可能比使用 android studio 签名时更大。
https://developer.android.com/studio/publish/app-signing.html#signing-manually
在使用 Android 构建 apk(android-debug.apk 或签名 android-release.apk 时无法初始化 JSON 存储工作室。当我使用 MFP CLI 模拟或使用 Cordova-debug.apk 时,相同的代码初始化 JSON 存储成功。
使用 MFP 7.1.0.00.20160217-1815
WL.JSONStore.init({test:{}}, {username:'abc',password:'abc'}).then(function (coll) {
console.log('Done',coll);
}).fail(function (error) {
console.log('Setup store error', error);
});
下面是抛出 INVALID_KEY_ON_PROVISION
错误的日志。这发生在应用程序的第一个 运行 上,所以我怀疑该错误是否与无效密码有关。如果没有提到集合,init 也会成功。
V/WindowManager( 1298): Adding window Window{1fe251eb u0 PopupWindow:ff4fcc1} at 3 of 6 (after Window{12c29fd0 u0 com.sample.app/com.sample.app.CordovaApp})
W/EGL_emulation( 5265): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 5265): Failed to set EGL_SWAP_BEHAVIOR on surface 0xe1d22080, error=EGL_SUCCESS
I/UsageStatsService( 1298): User[0] Flushing usage stats to disk
D/HttpPostRequestSender( 5265): WLHybridRequestSender.run in WLHybridRequestSender.java:42 :: Sending request http://192.168.1.124:10080/DemoRuntime/apps/services/random?bytes=32
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:553 :: os.arch: x86_64
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:574 :: Extracting zip file: featurelibs/x86/libcrypto.so.1.0.0
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:584 :: Loading library using System.load: /data/data/com.sample.app/files/libcrypto.so.1.0.0
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:589 :: com.mobileiron.wrapped is set to false
D/com.worklight.nativeandroid.common.WLUtils( 5265): WLUtils.loadLib in WLUtils.java:594 :: Loading library using System.load: /data/data/com.sample.app/files/libcrypto.so.1.0.0
E/JSONSTORE( 5265): JSONStoreLogger.logError in JSONStoreLogger.java:189 :: Error setting key
E/JSONSTORE( 5265): com.worklight.jsonstore.exceptions.JSONStoreInvalidPasswordException: Error setting key.
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.handleUsernameAndPassword(WLJSONStore.java:232)
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.provisionDatabase(WLJSONStore.java:148)
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.openCollections(WLJSONStore.java:347)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.ProvisionActionDispatcher.initializeCollection(ProvisionActionDispatcher.java:152)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.ProvisionActionDispatcher.databaseActionDispatch(ProvisionActionDispatcher.java:138)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.BaseDatabaseActionDispatcher.actionDispatch(BaseDatabaseActionDispatcher.java:36)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.dispatchers.BaseActionDispatcher.dispatch(BaseActionDispatcher.java:90)
E/JSONSTORE( 5265): at com.worklight.androidgap.plugin.DispatchingPlugin$ActionDispatcherRunnable.run(DispatchingPlugin.java:79)
E/JSONSTORE( 5265): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/JSONSTORE( 5265): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/JSONSTORE( 5265): at java.lang.Thread.run(Thread.java:818)
E/JSONSTORE( 5265): Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sample.app-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopenssl_fips.so"
E/JSONSTORE( 5265): at java.lang.Runtime.loadLibrary(Runtime.java:366)
E/JSONSTORE( 5265): at java.lang.System.loadLibrary(System.java:988)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.security.FipsWrapper.<clinit>(FipsWrapper.java:28)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.security.SecurityUtils.encrypt(SecurityUtils.java:68)
E/JSONSTORE( 5265): at com.worklight.androidgap.jsonstore.security.SecurityManager.storeDPK(SecurityManager.java:99)
E/JSONSTORE( 5265): at com.worklight.jsonstore.api.WLJSONStore.handleUsernameAndPassword(WLJSONStore.java:221)
E/JSONSTORE( 5265): ... 10 more
I/chromium( 5265): [INFO:CONSOLE(7)] "Setup store error", source: (7)
E/wl.jsonstore( 5265): {"src":"initCollection","err":-3,"msg":"INVALID_KEY_ON_PROVISION","col":"test","usr":"abc","doc":{},"res":{}}
作为解决方法,我已手动签署发布版本。这恰好有效,但 apk 可能比使用 android studio 签名时更大。 https://developer.android.com/studio/publish/app-signing.html#signing-manually