簡體   English   中英

IBM Worklight-直接更新后JSONStore無法初始化

[英]IBM Worklight - JSONStore fails to initialize after Direct Update

我將Worklight 6.0.0.2用於Android 4.4“ KitKit”中與JSONStore相關的修復。

除一個問題外,它工作正常:直接更新后,應用程序重新啟動,但是JSONStore初始化失敗; 如果我們然后退出該應用程序並重新啟動,那么它將運行良好。

在android 4.4中再現問題的步驟。 “奇巧”:

  1. 觸發直接更新
  2. 允許應用程序在更新后自行啟動

    然后您會在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)

  3. 關閉應用程序。
  4. 重新啟動。

里面的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM