contentful / vault

Easy persistence of Contentful data for Android over SQLite.
https://contentful.github.io/vault/
Apache License 2.0
85 stars 19 forks source link

Android crashes after a new field has been added #141

Closed eternalflamez closed 6 years ago

eternalflamez commented 6 years ago

When I add a new field to a model and then reference it in my Java model as such:

@Field
String newField

I get an error on the generated block in the "fromCursor" function:

java.lang.IllegalStateException: Couldn't read row 0, col 16 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
     at android.database.CursorWindow.nativeGetString(Native Method)
     at android.database.CursorWindow.getString(CursorWindow.java:438)
     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
     at -redacted-$$ModelHelper.fromCursor(CustomModel$$ModelHelper.java:70)
     at -redacted-$$ModelHelper.fromCursor(CustomModel$$ModelHelper.java:11)
     at com.contentful.vault.SqliteHelper.fromCursor(SqliteHelper.java:145)
     at com.contentful.vault.QueryResolver.all(QueryResolver.java:51)
     at com.contentful.vault.FetchQuery.resolveAll(FetchQuery.java:30)
     at com.contentful.vault.FetchQuery.resolveFirst(FetchQuery.java:37)
     at com.contentful.vault.LinkResolver.resourceForLink(LinkResolver.java:197)
     at com.contentful.vault.LinkResolver.getCachedResourceOrFetch(LinkResolver.java:96)
     at com.contentful.vault.LinkResolver.resolveLinksForField(LinkResolver.java:67)
     at com.contentful.vault.LinkResolver.resolveLinks(LinkResolver.java:55)
     at com.contentful.vault.QueryResolver.resolveLinks(QueryResolver.java:80)
     at com.contentful.vault.QueryResolver.all(QueryResolver.java:64)
     at com.contentful.vault.FetchQuery.resolveAll(FetchQuery.java:30)
     at com.contentful.vault.FetchQuery.all(FetchQuery.java:49)

The error is only fixed after I manually clear the app data and run it again.

kzotin commented 6 years ago

Hi, You need to bump up model version in space definition

eternalflamez commented 6 years ago

Ah, that does indeed fix the issue. Thanks!