Reputation: 199
I'm getting the below error:
Failed to find a code-generated model provider.
AWS amplify code which throwing this error:
Amplify.addPlugin(new AWSApiPlugin());
Amplify.addPlugin(new AWSDataStorePlugin());
Amplify.configure(context);
I am following the below tutorials:
https://docs.amplify.aws/start/getting-started/generate-model/q/integration/android https://docs.amplify.aws/cli/graphql-transformer/overview
I have tried generating models and models get generated successfully but still while running the app I am getting above exception.
Upvotes: 0
Views: 1481
Reputation: 52366
Your datasource needs to be updated:
Try running modelGen, then amplifyPush tasks:
Category | Resource name | Operation | Provider plugin |
---|---|---|---|
Api | amplifyDatasource | Update | awscloudformation |
Upvotes: 0
Reputation: 6659
When you generate models, you should expect to find various code-generated files in your application project. One of them will be app/src/main/java/com/amplifyframework/datastore/generated/model/AmplifyModelProvider.java
.
When you build your app, Android Studio will compile that java file into a class file, and include it into your binary.
At runtime, on the phone, the AWSDataStorePlugin()
constructor will attempt to find that same AmplifyModelProvider
by means of reflection.
I would verify that:
AmplifyModelProvider
;If you're still not able to get it working, just use the one-argument version of the AWSDataStorePlugin(...)
constructor, instead. That version allows you to explicitly specify the model provider, and does not use runtime reflection.
Amplify.addPlugin(AWSDataStorePlugin(AmplifyModelProvider.getInstance()))
Upvotes: 1