Start a new topic

NullPointerException in OfflineTable.insertEntity

I am getting this crash:



java.lang.NullPointerException

at com.kinvey.android.offline.OfflineTable.insertEntity(OfflineTable.java:168)

at com.kinvey.android.offline.AbstractSyncService$3.onSuccess(AbstractSyncService.java:186)

at com.kinvey.android.offline.AbstractSyncService$3.onSuccess(AbstractSyncService.java:183)

at com.kinvey.android.AsyncClientRequest.onPostExecute(AsyncClientRequest.java:91)

at android.os.AsyncTask.finish(AsyncTask.java:632)

at android.os.AsyncTask.access$600(AsyncTask.java:177)

at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:136)

at android.app.ActivityThread.main(ActivityThread.java:5001)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

at dalvik.system.NativeStart.main(Native Method)



when saving my object to the offline table. The crash happens in the background sync service process. This is using version 2.6.15 of the android lib jar.



We do have business logic executing on save, so this may be causing the returned JSON to be invalid. Is there any way I can see what is returned, or why this crash would occur?



Thanks
1 Comment

Hey,



That line in the OfflineTable class is confirming the existence of an `_id` within the object, before it is written to the local storage. It seems there is no _id field, so it crashing with a null pointer.



Try first enabling debug mode so you can see the raw HTTP requests and responses by following these instructions: http://devcenter.kinvey.com/android/guides/troubleshooting



Then, try setting the offline policy to "ALWAYS_ONLINE" and executing the same request-- you should see the original request going over the network, and eventually the response coming back. Double check that there is an `_id` field present in the response, and if it isn't then double check the business logic and ensure this field is forwarded on. Note that every entity coming back from a save request (PUT or POST) should contain an _id, provided by the Kinvey service if one doesn't exist.

Login or Signup to post a comment