aws-amplify / amplify-android

The fastest and easiest way to use AWS from your Android app.
https://docs.amplify.aws/lib/q/platform/android/
Apache License 2.0
245 stars 115 forks source link

Amplify DataStore Subscription failed #844

Closed Scarlett13 closed 4 years ago

Scarlett13 commented 4 years ago

My app is crashing several seconds after loading, without any apparent trigger:

{message=Subscription failed., cause=com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}

I'm using Amplify Android 1.3.2, running on a physical Android 10 device.

jamesonwilliams commented 4 years ago

@Scarlett13 Can you please provide:

  1. Your GraphQL schema;
  2. Relevant code snippets;
  3. Your amplifyconfiguration.json (with all credentials and IDs scrubbed out);
  4. Your system logs around the time of the error

The error looks like it should be received in an error callback. You say that it is crashing your app, though. How did the error surface to you?

Scarlett13 commented 4 years ago
  1. My schema look like:
type Self 
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "selfByNik", fields: ["selfnik"], queryField: "selfByNik")
@key(name: "selfByGender", fields: ["selfgender"], queryField: "selfByGender")
@key(name: "selfByNikByDob", fields: ["selfnik","selfdob"], queryField: "selfByNikByDob")
@key(name: "selfByNameByDob", fields: ["selfqueryname","selfdob"], queryField: "selfByNameByDob")
@key(name: "selfByDobByName", fields: ["selfdob","selfqueryname"], queryField: "selfByDobByName")
# @key(name: "selfByRegisteredFrom", fields: ["selfregisteredfrom"], queryField: "selfByRegisteredFrom")
{
    id: ID!
    selfcognitouserid: String
    selfqueryname: String! #perlu buat query byname
    selfpersonname: [SelfName] @connection(keyName: "bySelf", fields: ["id"])
    selfnik: String!
    selfidentitynumber: [SelfIdentityNumber] @connection(keyName: "bySelf", fields: ["id"])
    selfdob: String!
    selfplaceofbirth: String
    selfbloodtype: String
    selfgender: String!
    selfreligion: String
    selfmaritalstatus: String
    selftelephonenumber: [String]
    selfemail: [String]
    selfcitizenship: String
    selfrace: String
    selfactivesmoker: String # We have to use String type, because Boolean types cannot be sort keys
    selfeducationhistory: [SelfEducation] @connection(keyName: "bySelf", fields: ["id"])
    selfoccupationhistory: [SelfOccupation] @connection(keyName: "bySelf", fields: ["id"])
    selfallergy: [SelfAllergy] @connection(keyName: "bySelf", fields: ["id"])
    selfmedicalproblem: [SelfMedicalProblem!] @connection(keyName: "bySelf", fields: ["id"])
    selfrelationship: [SelfRelations] @connection(keyName: "bySelf", fields: ["id"])
    selfimagefile: [String] #should be s3 obj
    selfregisteredbyaccountid: String!
    selfvitalsign: [SelfVitalSign] @connection(keyName: "bySelfByDate", fields: ["id"])
    selfphysicalassessment: [SelfPhysicalAssessmemt] @connection(keyName: "bySelfByDate", fields: ["id"])
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfVitalSign
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid"])
@key(name: "bySelfByDate", fields: ["selfid", "createdOn"])
{
    id: ID!
    selfid: ID
    systole: String
    diastole: String
    heartrate: String
    resprate: String
    temperature: String
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfPhysicalAssessmemt
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid"])
@key(name: "bySelfByDate", fields: ["selfid", "createdOn"])
{
    id: ID!
    selfid: ID
    bodyheight: String
    bodyweight: String
    waist: String
    headcircumference: String
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfRelations
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid"])
{
    id:ID!
    selfid:ID!
    relationsid: ID!
    relationshiptype: String!
    relationshipsexualstatus: String
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfName 
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid", "fullname"])
{
    id:ID!
    selfid:ID!
    fullname: String!
    firstname: String!
    lastname: String
    preferredname: [String]
    createdOn: AWSDateTime #
    updatedOn: AWSDateTime #
}

type SelfAllergy
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid"])
{
    id: ID!
    selfid: ID
    allergytype: String!
    allergydesc: String!
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfMedicalProblem
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid"])
{
    id: ID!
    selfid: ID
    medicalproblem: String!
    medicalproblemdescription: String!
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfIdentityNumber
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid", "idnumber"])
{
    id: ID!
    selfid: ID
    identitynumbertype: String!
    idnumber: String!
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfOccupation
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid", "institutioncountry"])
{
    id:ID!
    selfid:ID
    institutioncountry: String!
    institutionname: String!
    role: String!
    startdate: String!
    enddate: String!
    occupationstatus: String!
    createdOn: AWSDateTime! #
    updatedOn: AWSDateTime! #
}

type SelfEducation
@model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"})
@key(name: "bySelf", fields: ["selfid", "institutionname"])
{
    id:ID!
    selfid:ID
    educationlevel: String!
    institutionname: String!
    enrolmentdate: String!
    graduationdate: String!
    leavingdate: String
    leavingreasons: [String]
    lastgrades: String
    createdOn: AWSDateTime #
    updatedOn: AWSDateTime #
}
  1. for the code snippets, im not even doing anything yet with the data store, it crashes when the datastore tried to sync with the API.

  2. the amplifyconfiguration.json:

    {
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify-cli/0.1.0",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "ap-southeast-1:xxx",
                            "Region": "ap-southeast-1"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "ap-southeast-poolid",
                        "AppClientId": "id",
                        "AppClientSecret": "secret",
                        "Region": "ap-southeast-1"
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH"
                    }
                },
                "S3TransferUtility": {
                    "Default": {
                        "Bucket": "bucket-dev",
                        "Region": "ap-southeast-1"
                    }
                },
                "AppSync": {
                    "Default": {
                        "ApiUrl": "url",
                        "Region": "ap-southeast-1",
                        "AuthMode": "AMAZON_COGNITO_USER_POOLS",
                        "ClientDatabasePrefix": "apiname_AMAZON_COGNITO_USER_POOLS"
                    },
                    "apiname_API_KEY": {
                        "ApiUrl": "urlxxx",
                        "Region": "ap-southeast-1",
                        "AuthMode": "API_KEY",
                        "ApiKey": "xxx",
                        "ClientDatabasePrefix": "apiname_API_KEY"
                    }
                },
                "PinpointAnalytics": {
                    "Default": {
                        "AppId": "xxx",
                        "Region": "us-west-2"
                    }
                },
                "PinpointTargeting": {
                    "Default": {
                        "Region": "us-west-2"
                    }
                }
            }
        }
    },
    "storage": {
        "plugins": {
            "awsS3StoragePlugin": {
                "bucket": "xxx-dev",
                "region": "ap-southeast-1",
                "defaultAccessLevel": "guest"
            }
        }
    },
    "analytics": {
        "plugins": {
            "awsPinpointAnalyticsPlugin": {
                "pinpointAnalytics": {
                    "appId": "xxx",
                    "region": "us-west-2"
                },
                "pinpointTargeting": {
                    "region": "us-west-2"
                }
            }
        }
    },
    "api": {
        "plugins": {
            "awsAPIPlugin": {
                "apiname": {
                    "endpointType": "GraphQL",
                    "endpoint": "xxx",
                    "region": "ap-southeast-1",
                    "authorizationType": "AMAZON_COGNITO_USER_POOLS",
                    "apiKey": "xxx"
                }
            }
        }
    },
    "datastore": {
        "plugins": {
            "awsDataStorePlugin": {
                "apiName": "apiname"
            }
        }
    }
    }
  3. The system log:

2020-09-19 10:54:49.256 29619-30058/com.cryptoscope_.cts_doctor W/amplify:aws-api: Websocket connection failed.
    com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it.
        at com.amplifyframework.api.aws.IterableDeserializer.deserialize(IterableDeserializer.java:87)
        at com.amplifyframework.api.aws.IterableDeserializer.deserialize(IterableDeserializer.java:34)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:1003)
        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.parseErrors(GraphQLResponseDeserializer.java:97)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.deserialize(GraphQLResponseDeserializer.java:54)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.deserialize(GraphQLResponseDeserializer.java:32)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:897)
        at com.google.gson.Gson.fromJson(Gson.java:846)
        at com.amplifyframework.api.aws.GsonGraphQLResponseFactory.buildResponse(GsonGraphQLResponseFactory.java:53)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$Subscription.dispatchNextMessage(SubscriptionEndpoint.java:370)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.notifySubscriptionData(SubscriptionEndpoint.java:220)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.access$600(SubscriptionEndpoint.java:60)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.processJsonMessage(SubscriptionEndpoint.java:546)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onMessage(SubscriptionEndpoint.java:454)
        at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.kt:333)
        at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.kt:245)
        at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:106)
        at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

and repetitive log like (it happens for almost table and subscription error: ON_UPDATE, ON_CREATE):

2020-09-19 10:54:49.260 29619-30058/com.cryptoscope_.cts_doctor W/amplify:aws-datastore:     at com.amplifyframework.api.aws.SubscriptionEndpoint.notifySubscriptionData(SubscriptionEndpoint.java:220)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.access$600(SubscriptionEndpoint.java:60)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.processJsonMessage(SubscriptionEndpoint.java:546)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onMessage(SubscriptionEndpoint.java:454)
        at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.kt:333)
        at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.kt:245)
        at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:106)
        at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
            ... 4 more
2020-09-19 10:54:49.263 29619-30058/com.cryptoscope_.cts_doctor W/amplify:aws-datastore: An error occurred on the remote SelfIdentityNumber subscription for model ON_UPDATE.
    AmplifyException {message=Error during subscription., cause=AmplifyException {message=Subscription failed., cause=com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Evaluate details.}
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$subscription$3(AppSyncClient.java:293)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$8gXTT9bgLZGP51blif6hkh7EwIc.accept(Unknown Source:4)
        at com.amplifyframework.api.aws.SubscriptionOperation.lambda$null$1$SubscriptionOperation(SubscriptionOperation.java:94)
        at com.amplifyframework.api.aws.-$$Lambda$SubscriptionOperation$EfR-sAOj2xzA_-vAoxWBdb2iFk8.accept(Unknown Source:4)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$Subscription.dispatchError(SubscriptionEndpoint.java:377)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.notifyError(SubscriptionEndpoint.java:204)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.access$000(SubscriptionEndpoint.java:60)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onFailure(SubscriptionEndpoint.java:473)
        at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.kt:592)
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:197)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: AmplifyException {message=Subscription failed., cause=com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
        at com.amplifyframework.api.aws.SubscriptionEndpoint.notifyError(SubscriptionEndpoint.java:204) 
        at com.amplifyframework.api.aws.SubscriptionEndpoint.access$000(SubscriptionEndpoint.java:60) 
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onFailure(SubscriptionEndpoint.java:473) 
        at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.kt:592) 
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:197) 
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 
     Caused by: com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it.
        at com.amplifyframework.api.aws.IterableDeserializer.deserialize(IterableDeserializer.java:87)
        at com.amplifyframework.api.aws.IterableDeserializer.deserialize(IterableDeserializer.java:34)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:1003)
        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.parseErrors(GraphQLResponseDeserializer.java:97)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.deserialize(GraphQLResponseDeserializer.java:54)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.deserialize(GraphQLResponseDeserializer.java:32)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:897)
        at com.google.gson.Gson.fromJson(Gson.java:846)
        at com.amplifyframework.api.aws.GsonGraphQLResponseFactory.buildResponse(GsonGraphQLResponseFactory.java:53)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$Subscription.dispatchNextMessage(SubscriptionEndpoint.java:370)

i think log that causes the crash is:

2020-09-19 10:54:49.280 29619-30289/? E/AndroidRuntime: FATAL EXCEPTION: RxCachedThreadScheduler-69
    Process: com.cryptoscope_.cts_doctor, PID: 29619
    io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | AmplifyException {message=Error during subscription., cause=AmplifyException {message=Subscription failed., cause=com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Evaluate details.}
        at io.reactivex.rxjava3.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
        at io.reactivex.rxjava3.internal.util.AtomicThrowable.tryAddThrowableOrReport(AtomicThrowable.java:52)
        at io.reactivex.rxjava3.internal.operators.observable.ObservableFlatMap$InnerObserver.onError(ObservableFlatMap.java:531)
        at io.reactivex.rxjava3.internal.observers.BasicFuseableObserver.onError(BasicFuseableObserver.java:100)
        at io.reactivex.rxjava3.internal.observers.BasicFuseableObserver.onError(BasicFuseableObserver.java:100)
        at io.reactivex.rxjava3.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated(ObservableObserveOn.java:281)
        at io.reactivex.rxjava3.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:172)
        at io.reactivex.rxjava3.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
        at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65)
        at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: AmplifyException {message=Error during subscription., cause=AmplifyException {message=Subscription failed., cause=com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Evaluate details.}
        at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$subscription$3(AppSyncClient.java:293)
        at com.amplifyframework.datastore.appsync.-$$Lambda$AppSyncClient$8gXTT9bgLZGP51blif6hkh7EwIc.accept(Unknown Source:4)
        at com.amplifyframework.api.aws.SubscriptionOperation.lambda$null$1$SubscriptionOperation(SubscriptionOperation.java:94)
        at com.amplifyframework.api.aws.-$$Lambda$SubscriptionOperation$EfR-sAOj2xzA_-vAoxWBdb2iFk8.accept(Unknown Source:4)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$Subscription.dispatchError(SubscriptionEndpoint.java:377)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.notifyError(SubscriptionEndpoint.java:204)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.access$000(SubscriptionEndpoint.java:60)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onFailure(SubscriptionEndpoint.java:473)
        at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.kt:592)
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:197)

and this:

2020-09-19 10:54:49.281 29619-30289/? E/AndroidRuntime:     at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
            ... 3 more
     Caused by: AmplifyException {message=Subscription failed., cause=com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it., recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
            ... 9 more
     Caused by: com.google.gson.JsonParseException: Got JSON from an API call which was supposed to go with a List but is in the form of an object rather than an array. It also is not in the standard format of having an items property with the actual array of data so we do not know how to deserialize it.
        at com.amplifyframework.api.aws.IterableDeserializer.deserialize(IterableDeserializer.java:87)
        at com.amplifyframework.api.aws.IterableDeserializer.deserialize(IterableDeserializer.java:34)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:1003)
        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.parseErrors(GraphQLResponseDeserializer.java:97)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.deserialize(GraphQLResponseDeserializer.java:54)
        at com.amplifyframework.api.aws.GraphQLResponseDeserializer.deserialize(GraphQLResponseDeserializer.java:32)
        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
        at com.google.gson.Gson.fromJson(Gson.java:932)
        at com.google.gson.Gson.fromJson(Gson.java:897)
        at com.google.gson.Gson.fromJson(Gson.java:846)
        at com.amplifyframework.api.aws.GsonGraphQLResponseFactory.buildResponse(GsonGraphQLResponseFactory.java:53)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$Subscription.dispatchNextMessage(SubscriptionEndpoint.java:370)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.notifySubscriptionData(SubscriptionEndpoint.java:220)
        at com.amplifyframework.api.aws.SubscriptionEndpoint.access$600(SubscriptionEndpoint.java:60)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.processJsonMessage(SubscriptionEndpoint.java:546)
        at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onMessage(SubscriptionEndpoint.java:454)
        at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.kt:333)
        at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.kt:245)
        at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:106)
        at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
        at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
            ... 4 more

thanks for your reply, @jamesonwilliams ! Really appreciate it.

alcarlos1 commented 4 years ago

I had the same problem, all the com.amplifyframework dependencies was not up to date: 1.3.1 instead of 1.3.2. @jamesonwilliams, can you modify the Getting Started guide to avoid the misleading info?

rjuliano commented 4 years ago

Just created https://github.com/aws-amplify/docs/pull/2435

jamesonwilliams commented 4 years ago

@Scarlett13 Does @alcarlos1's suggestion resolve your problem? Does this error persist if you use 1.3.2 equally, for all dependencies?

Scarlett13 commented 4 years ago

@jamesonwilliams I can confirm that the issue is gone when I start a new fresh project and I dont know why. Even tho I used the same setup in the existing project (amplify cli setup and gradle setup), the issue still persists. Maybe it is my schema that gone wrong. I will try to wipe the amplify project completely and add a new and fresh one. Hopefully that could solve my issue. For now, I will closed this issue. Thanks.