Start a new topic

null value in KinveyListCallback [Android]

I sent this as an email as well, but just to get this issue out in the open:

I'm trying attempting to use the Android library, and am running into trouble with the onSuccess method of KinveyListCallback.

Right now I'm calling appData.get(query, new KinveyListCallback...) where query is an empty Query, but the result in onSuccess is just null. As far as I can tell, this is an undocumented behavior of the library. Is there any circumstance where that library would provide "null" in a success handler?

Hey, there are two common reasons this can happen:

1. Ensure your `GenericJson` class has a `public`, no-args constructor. Also, if it is an inner class, it also must be `public static`.

2. Ensure the types of the fields in your `GenericJson` class match what is stored in your backend. For example, "2" is a String, while 2 is a Number.
I managed to fix the problem by moving my subclass of GenericJson out of its enclosing class into its own file. I can't really tell if this is a Kinvey issue or a gson issue, but it may be worth noting in the docs you must define your custom class in its own file, otherwise all of the success handlers will return null.
Login or Signup to post a comment