android 的 Simperium 简单待办事项演示代码出错

Error in simple todo demo code of Simperium for android

我下载了 demo code.

在运行之后代码:

我收到这个屏幕。我在其他设备上使用相同的用户名和 ID 登录,但没有任何反应。

输入文本时出现以下错误:

11-30 18:29:58.731  14566-16417/com.simperium.simpletodo E/SQLiteDatabase﹕ Error inserting bucketName=todo changeVersion=
    android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: changeVersions.bucketName (code 2067)
            at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
            at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:780)
            at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
            at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
            at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1471)
            at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
            at com.simperium.android.GhostStore.setChangeVersion(GhostStore.java:98)
            at com.simperium.client.Bucket.setChangeVersion(Bucket.java:416)
            at com.simperium.client.Bucket.indexComplete(Bucket.java:411)
            at com.simperium.client.Channel$IndexProcessor.notifyDone(Channel.java:1126)
            at com.simperium.client.Channel$IndexProcessor.next(Channel.java:1039)
            at com.simperium.client.Channel$IndexProcessor.addIndexPage(Channel.java:1107)
            at com.simperium.client.Channel$IndexProcessor.start(Channel.java:994)
            at com.simperium.client.Channel.updateIndex(Channel.java:397)
            at com.simperium.client.Channel.access0(Channel.java:38)
            at com.simperium.client.Channel.execute(Channel.java:187)
            at com.simperium.client.Channel$CommandInvoker.executeCommand(Channel.java:743)
            at com.simperium.client.Channel.executeCommand(Channel.java:713)
            at com.simperium.client.Channel.receiveMessage(Channel.java:667)
            at com.simperium.android.WebSocketManager.onMessage(WebSocketManager.java:420)
            at com.simperium.android.WebSocketManager.onMessage(WebSocketManager.java:211)
            at com.simperium.android.AsyncWebSocketProvider.onStringAvailable(AsyncWebSocketProvider.java:85)
            at com.koushikdutta.async.http.WebSocketImpl.onMessage(WebSocketImpl.java:88)
            at com.koushikdutta.async.http.HybiParser.emitFrame(HybiParser.java:420)
            at com.koushikdutta.async.http.HybiParser.access0(HybiParser.java:46)
            at com.koushikdutta.async.http.HybiParser.onDataAvailable(HybiParser.java:197)
            at com.koushikdutta.async.DataEmitterReader.handlePendingData(DataEmitterReader.java:24)
            at com.koushikdutta.async.DataEmitterReader.onDataAvailable(DataEmitterReader.java:41)
            at com.koushikdutta.async.Util.emitAllData(Util.java:22)
            at com.koushikdutta.async.AsyncSSLSocketWrapper.onDataAvailable(AsyncSSLSocketWrapper.java:230)
            at com.koushikdutta.async.AsyncSSLSocketWrapper.onDataAvailable(AsyncSSLSocketWrapper.java:217)
            at com.koushikdutta.async.Util.emitAllData(Util.java:22)
            at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:146)
            at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:788)
            at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:626)
            at com.koushikdutta.async.AsyncServer.access0(AsyncServer.java:41)
            at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:568)

请知道的朋友帮忙!

错误状态:

UNIQUE constraint failed: changeVersions.bucketName

bucketName 有一个 UNIQUE 约束,这意味着每个新插入的值都必须是唯一的。

因此您尝试插入一个对象,其 bucketName 已存在于数据库中。

如果您认为可以有多个对象具有相同的 bucketName,请取消限制。

如果不应该,在插入之前检查是否已经存在,并优雅地处理它。

演示应用依靠软键盘添加新项目,因此请确保在您的模拟器或设备中启用它。

我将研究 sql 错误,但它似乎只显示在模拟器日志中,而不是在真实设备上。