App freezes when invoking Amplify.DataStore.save()
See original GitHub issueI’m using Kotlin and AWS Amplify to make a simple mobile app. I’ll begin by
showing what I have setup. My schema.graphql
:
type OfferGQL @model {
id: ID!
name: String!
description: String!
address: String!
price: Float!
}
My AWS plugins are setup like this:
Amplify.addPlugin(AWSCognitoAuthPlugin())
Amplify.addPlugin(AWSS3StoragePlugin())
Amplify.addPlugin(AWSDataStorePlugin())
Amplify.configure(applicationContext)
This is how I try to save my data to the DataStore:
// Create a new offer object
val newOffer = OfferGQL.builder()
.name(textFieldOfferName.text.toString())
.description(textFieldOfferDescription.text.toString())
.address(textFieldOfferAddress.text.toString())
.price(textFieldOfferPrice.text.toString().toFloat())
.build()
// Put it in the DataStore
Amplify.DataStore.save(newOffer,
{ result ->
runOnUiThread{Toast.makeText(this,"Offer added successfully", Toast.LENGTH_LONG).show()}
},
{ error ->
println(error.message)
println(error.localizedMessage)
println(error.cause)
println(error.recoverySuggestion)
}
)
The problem is that when I invoke Amplify.DataStore.save(...)
, the entire app
freezes. I followed the documentation to configure everything so I don’t really
know why this is happening.
(Also asked this on StackOverflow.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
App freezes when invoking Amplify.DataStore.save()
The problem is that when I invoke Amplify.DataStore.save() the entire app freezes. I followed the documentation to configure everything so I ...
Read more >DataStore - Other methods - Swift - AWS Amplify Docs
To stop the DataStore sync process, you can use DataStore.stop() . This will close the real time subscription connection when your app is...
Read more >DataStore - Getting started - Flutter - AWS Amplify Docs
Troubleshooting: Cloud sync will fail without the conflict detection configuration. To enable it for an existing project, run amplify update api and choose ......
Read more >Build fast React Native apps with AWS Amplify
In this article, we will be building a mobile application with React Native using Expo SQLite adapter as a storage adapter for DataStore....
Read more >amplify_datastore | Flutter Package - Pub.dev
Invoke Amplify.DataStore.clear() on App start after upgrading to the latest version of Amplify Flutter. This API clears and recreates local database table ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jamesonwilliams Yes signing in fixes that. Once again, the fix for the original bug is a complete reinstall of the app so I’m closing this for now. Thanks for the communication!
@Zablas Based on the bottom of your stack trace, it looks like you haven’t signed-in any user. It also looks like you’ve configured this API to use Cognito. As a result, the DataStore is not able to sync, since it trying to use Cognito authentication when talking to AppSync.
TLDR: did you complete a successful
Amplify.Auth.signIn(...)
?