Reputation: 1
I have a table in AWS DynamoDB , I integrated it with my Android Application using AWS Amplify by using the steps explained in - Amplify docs , after the integration is done, while I am trying to run a query to fetch data from my table, the app is running but I am getting error in the logcat as :
Failure encountered while attempting to start API sync
DataStoreException{message=DataStore subscriptionProcessor failed to
start., cause=GraphQLResponseException{message=Subscription error for Todo
Caused by: GraphQLResponseException{message=Subscription error for Todo: [GraphQLResponse.Error{message='Validation error of type FieldUndefined Field '_deleted' in type 'Todo' is undefined @ 'onUpdateTodo/_deleted'', locations='null', path='null', extensions='null'}, GraphQLResponse.Error{message='Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'Todo' is undefined @ 'onUpdateTodo/_lastChangedAt'', locations='null', path='null', extensions='null'}, GraphQLResponse.Error{message='Validation error of type FieldUndefined: Field '_version' in type 'Todo' is undefined @ 'onUpdateTodo/_version'', locations='null', path='null', extensions='null'}], recoverySuggestion=See attached list of GraphQLResponse.Error objects.}
This is my code:
private void fetchTodo() {
String todoId = ""; //here i am giving the id of the data that i want to fetch
Amplify.DataStore.query(
Todo.class,
Todo.ID.eq(todoId),
todos -> {
if (todos.hasNext()) {
Todo todo = todos.next();
runOnUiThread(() -> {
name.setText(todo.getName());
priority.setText(todo.getPriority().ordinal());
update.setText(todo.getUpdatedAt().getOffsetTotalSeconds());
});
} else {
Log.i("Tutorial", "No Todo found with the specified ID.");
}
},
failure -> Log.e("Tutorial", "Could not query DataStore", failure)
);
}
}
I followed the amplify docs documentation and built multiple projects , but this was the common issue in every project. I want to add and fetch data from my table in the app programmatically.
Upvotes: 0
Views: 74
Reputation: 10734
If you are working in Android, use the AWS SDK for Kotlin. This SDK works great in Android Studio projects when building Native Android apps.
The AWS SDK for Kotlin is designed to work seamlessly with Kotlin, the primary programming language for Android development. It provides full support for Kotlin features, such as Coroutines, which can make your code more concise, readable, and easier to work with asynchronous operations.
See the Kotlin DEV guide here:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
DynamoDB code examples for this SDK are here:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/dynamodb
Here is a walk through that shows you how to build an Android Studio project with this SDK that invokes AWS Services:
Upvotes: 0