[英]IBM Worklight - JSONStore fails to initialize after Direct Update
我将Worklight 6.0.0.2用于Android 4.4“ KitKit”中与JSONStore相关的修复。
除一个问题外,它工作正常:直接更新后,应用程序重新启动,但是JSONStore初始化失败; 如果我们然后退出该应用程序并重新启动,那么它将运行良好。
在android 4.4中再现问题的步骤。 “奇巧”:
允许应用程序在更新后自行启动
然后您会在LogCat中看到:
05-13 16:28:57.010:E / jsonstore-core(16691):验证架构错误05-13 16:28:57.010:E / jsonstore-core(16691):java.lang.Throwable:名称为“ _id”的节点”已存在于架构05-13 16:28:57.010中:E / jsonstore-core(16691):位于com.worklight.androidgap.jsonstore.database.DatabaseSchema.addNode(DatabaseSchema.java:124)
里面的initoptions.js
var wlInitOptions = {
connectOnStartup : false,
heartBeatIntervalInSecs : 5,
logger : {
enabled : true,
level : 'debug',
stringify : true,
pretty : false,
tag : {
level : false,
pkg : true
},
whitelist : [],
blacklist : []
},
analytics : {
enabled : false
},
};
里面的JS文件:
function wlCommonInit(){
collections["Videos"] = {
searchFields:{"BrandID":"string","VideoType":"string","CategoryID":"string","CourseID":"string","ISDeleted":"string","IsDownload":"string","VideoID":"string"}
};
var options = {"username":"*","password":"*","localKeyGen":false,"clear":false};
WL.JSONStore.init(collections, options)
.then(function (resp) {
Brands=WL.JSONStore.get('Brands');
Categories=WL.JSONStore.get('Categories');
Courses=WL.JSONStore.get('Courses');
Videos=WL.JSONStore.get('Videos');
Notification=WL.JSONStore.get('Notification');
UserInformationColl = WL.JSONStore.get('UserInformation');
BrandListCollection = WL.JSONStore.get('BrandList');
VideosList = WL.JSONStore.get('VideoList');
BusinessType= WL.JSONStore.get('BusinessType');
connectToServer();
// initializeAnalytics(2000,131);
var query={"IsDownload":"2"};
WL.JSONStore.get('Videos').find(query, {exact:true})
.then(function (result2) {
if(result2.length > 0){
for(var i=0; i<result2.length; i++){
result2[i].json.IsDownload = 0;
Videos.replace(result2[i], {})
.then(function (numberOfDocumentsReplaced) {
WL.Logger.info("The number of document replaced are:--->"+numberOfDocumentsReplaced);
})
.fail(function (errorObject) {
WL.Logger.error("Error in document:---->"+errorObject);
});
}
}
errorvideodownloading();
})
.fail(function (errorObject) {
WL.Logger.debug('error' +errorObject.toString());
});
})
.fail(function (errorObject) {
WL.Logger.error("init notification error:----->"+errorObject);
if(errorObject.err === -2){
WL.Logger.error("In the errorObject so destroying JSON store and recreating it.");
WL.JSONStore.destroy();
JsonStoreinit();
localStorage.clear();
connectToServer();
}
else if(errorObject.err === 16)
{
hideSplashScreenPlatForm();
}
});
}
else{
WL.Logger.debug('[JSONStore] Check your dependencies.');
}
}catch(e){
WL.Logger.error("Exception is:--->"+e);
}
}
不确定您的初始化代码。 但是你会得到类似的错误
java.lang.Throwable: node with name "_id" already exists in schema
当您使用集合时,直到成功回调。
有关更多信息,请参见此答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.