Android app crashes when using SDK listener


#1

when using the following SDK call in my application:
nest.addCameraListener(new NestListener.CameraListener() {
@Override
public void onUpdate(@NonNull ArrayList cameras) {
// Handle camera update…

            Log.d("dogfedCustom",cameras.toString());
        }
    });

Application Crashes showing the following output:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.solvit.dogfeeder, PID: 30007
com.firebase.client.FirebaseException: Failed to bounce to type
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:186)
at com.nestlabs.sdk.CameraValueListener.onDataChange(CameraValueListener.java:45)
at com.firebase.client.core.ValueListenerContainer$1.run(ValueListenerContainer.java:47)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field “has_person” (class com.nestlabs.sdk.Camera$LastEvent), not marked as ignorable (10 known properties: , “web_url”, “has_sound”, “start_time”, “image_url”, “animated_image_url”, “app_url”, “end_time”, “urls_expire_time”, “activity_zone_ids”, “has_motion”])
at [Source: {“snapshot_url”:“https://www.dropcam.com/api/wwn.get_snapshot/CjY1VmNYVkkyXzhyZTZGUnVSWGx3QWlzOE5INkJ4dVRfc1ZKRVJvdmZVNnl2Q0JTMTZVQ2tiV2cSFkZvQTNEbnd4cjVlaVJnNllwUk1ZY3caNmwxSDBFS054cmVGRTJCSHBPaThhOURZMkxVZGhTZzJfZGRoeTFZRF9YWjEyYlhrSlJlNEZGUQ?auth=c.OypQf9FM0tlcWdqwprqnzAGx4Gr6ut0CRZu0yCO7Ibeg8HnWs8R1kCj3bui27HQdJ845LUBv0ApPIzguESCuc90bgZtSSucf6QDBGbnLqj2izuvCMD8vkNO5aCLfSh9bBfzW34QuRQiaPNj1",“is_online”:true,“app_url”:“nestmobile://cameras/CjY1VmNYVkkyXzhyZTZGUnVSWGx3QWlzOE5INkJ4dVRfc1ZKRVJvdmZVNnl2Q0JTMTZVQ2tiV2cSFkZvQTNEbnd4cjVlaVJnNllwUk1ZY3caNmwxSDBFS054cmVGRTJCSHBPaThhOURZMkxVZGhTZzJfZGRoeTFZRF9YWjEyYlhrSlJlNEZGUQ?auth=c.OypQf9FM0tlcWdqwprqnzAGx4Gr6ut0CRZu0yCO7Ibeg8HnWs8R1kCj3bui27HQdJ845LUBv0ApPIzguESCuc90bgZtSSucf6QDBGbnLqj2izuvCMD8vkNO5aCLfSh9bBfzW34QuRQiaPNj1”,“web_url”:“https://home.nest.com/cameras/CjY1VmNYVkkyXzhyZTZGUnVSWGx3QWlzOE5INkJ4dVRfc1ZKRVJvdmZVNnl2Q0JTMTZVQ2tiV2cSFkZvQTNEbnd4cjVlaVJnNllwUk1ZY3caNmwxSDBFS054cmVGRTJCSHBPaThhOURZMkxVZGhTZzJfZGRoeTFZRF9YWjEyYlhrSlJlNEZGUQ?auth=c.OypQf9FM0tlcWdqwprqnzAGx4Gr6ut0CRZu0yCO7Ibeg8HnWs8R1kCj3bui27HQdJ845LUBv0ApPIzguESCuc90bgZtSSucf6QDBGbnLqj2izuvCMD8vkNO5aCLfSh9bBfzW34QuRQiaPNj1”,“is_public_share_enabled”:false,“last_is_online_change”:“2018-04-26T17:11:17.000Z”,“device_id”:“5VcXVI2_8re6FRuRXlwAis8NH6BxuT_sVJERovfU6yvCBS16UCkbWg”,“where_name”:“Driveway”,“last_event”:{“start_time”:“2018-04-30T14:04:21.160Z”,“end_time”:“2018-04-30T14:05:10.790Z”,“has_motion”:true,“has_sound”:false,“has_person”:false},“name”:“Driveway”,“structure_id”:“HPKgJuWbxE6cgCkeCy-JdHtt0pGSx8r7-QlK5WsOXPuKsl74s5WdMw”,“where_id”:“ZAHbChs3VXdE7WM-iw35IbTCrZ0e-YZrhHNeQcyl3g3JhUvvUjFgtQ”,“software_version”:“217-610040”,“name_long”:"Driveway Camera”,“is_streaming”:true,“is_video_history_enabled”:false,“is_audio_input_enabled”:true}; line: 1, column: 1483] (through reference chain: com.nestlabs.sdk.Camera[“last_event”]->com.nestlabs.sdk.LastEvent[“has_person”])
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:708)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1160)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:315)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:464)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:107)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:295)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDe


#2

Hi anking, the error is indicating an issue with “has_person” but the snapshot_url is returning has_person, and the SDK has this property within Camera.last_event. Please check which camera permissions you have, and which Nest Cam(s) you are testing, and any other relevant code and we can try to reproduce it.

You can also try to add this to see if it changes the issue:
@JsonIgnoreProperties(ignoreUnknown=true)
-thanks


#3

Becky,

I have /Camera + Images read/write v4/ permissions for the application.(these are the only permissions for the app, and i tried just reav and V3 without any luck). do i need any additional permissions to view cameras?

I have 2 outdoor nest cameras.

@JsonIgnoreProperties(ignoreUnknown=true) - has no effect.

Really stumped over this. not sure what to do from here


#4

Yes it looks like from the JSON you are getting back, that you have the permissions and the API for your Nest Cam has this property. Do you have a Nest Cam IQ or is it a previous model? It could be the version of Android or other libraries is newer and handling the mapping differently.
We can look into this and see if this is any indication of the error, since the path looks wrong (missing Camera):
line: 1, column: 1483] (through reference chain: com.nestlabs.sdk.Camera[“last_event”]->com.nestlabs.sdk.LastEvent[“has_person”])


#5

Becky,

I ended up downloading SDK and edited Camera.java. I added “has_person” property to the LastEvent class using existing analogy. It works now, but i think SDK needs to be fixed to reflect this new property.


#6

Thanks anking, glad it’s working.
Just to confirm, are you getting the code from https://github.com/nestlabs/android-sdk, because has_person is in https://github.com/nestlabs/android-sdk/blob/master/sdk/src/main/java/com/nestlabs/sdk/models/Camera.java but there may be older branches that don’t have this property:
/**
* LastEvent contains information about the last event that triggered a notification. In order
* to capture last event data, the Nest Cam must have a Nest Aware with Video History
* subscription.
*/
static class LastEvent implements Parcelable {
public static final String KEY_HAS_SOUND = “has_sound”;
public static final String KEY_HAS_MOTION = “has_motion”;
public static final String KEY_HAS_PERSON = “has_person”;
public static final String KEY_START_TIME = “start_time”;

@JsonProperty(KEY_HAS_SOUND)
private boolean mHasSound;

    @JsonProperty(KEY_HAS_MOTION)
    private boolean mHasMotion;

    @JsonProperty(KEY_HAS_PERSON)
    private boolean mHasPerson;

    @JsonProperty(KEY_START_TIME)
    private String mStartTime;


Thanks again for your updates.


#7

Becky,

This is weird. Id does seem to have that property. But when i download it (version 1.1.1) it doesnt!
I just tried it again now, and it doesn’t make a lot of sense to me now!

I guess this is why it doesn’t work when i do:
compile 'com.nestlabs:android-sdk:1.1.1'