Error in simple todo demo code of Simperium for android

151 views Asked by At

I downloaded the demo code.

After running the code :

Screenshot

I am getting this screen. I signed in with same username and id on other device, but nothing is happening.

On entering text, I'm getting the following error :

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.access$100(Channel.java:38)
            at com.simperium.client.Channel$2.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$2.onMessage(WebSocketManager.java:211)
            at com.simperium.android.AsyncWebSocketProvider$1$2.onStringAvailable(AsyncWebSocketProvider.java:85)
            at com.koushikdutta.async.http.WebSocketImpl$1.onMessage(WebSocketImpl.java:88)
            at com.koushikdutta.async.http.HybiParser.emitFrame(HybiParser.java:420)
            at com.koushikdutta.async.http.HybiParser.access$800(HybiParser.java:46)
            at com.koushikdutta.async.http.HybiParser$5.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$5.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.access$700(AsyncServer.java:41)
            at com.koushikdutta.async.AsyncServer$13.run(AsyncServer.java:568)

Please help if anyone knows about it!

2

There are 2 answers

5
roundhill On BEST ANSWER

The demo app relies on the soft keyboard to add new items, so make sure to have it enabled in your emulator or device.

I'll research the sql error, but it appears to only show in the emulator log and not on a real device.

1
Daniel Zolnai On

The error states:

UNIQUE constraint failed: changeVersions.bucketName

bucketName has a UNIQUE constraint, which means that each new inserted value has to be unique.

So you tried to insert an object with a bucketName which already existed in the database.

If you think you can have multiple objects with the same bucketName, remove the constraint.

If you shouldn't, check before inserting if there's already one, and handle it gracefully.