question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App freezes when invoking Amplify.DataStore.save()

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Zablascommented, Aug 17, 2020

@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!

0reactions
jamesonwilliamscommented, Aug 17, 2020

@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(...)?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found