I am trying to use AWS Amplify's AmplifyStorageS3,AmplifyAPI and AmplifyAuthCognito with my flutter app. I follow the documentation and everything is working fine but some time app crashes on Android 10 with following error
Fatal Exception: java.lang.IllegalStateException: Tried to get a plugin before it was configured. Make sure you call Amplify.configure() first. at com.amplifyframework.core.category.Category.getPluginIfConfiguredOrThrow(Category.java:75) at com.amplifyframework.core.category.Category.getSelectedPlugin(Category.java:31) at com.amplifyframework.api.ApiCategory.query(ApiCategory.java) at com.amazonaws.amplify.amplify_api.FlutterGraphQLApi$query$2.invokeSuspend(FlutterGraphQLApi.java:61) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:9) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:94) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:14) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.java:28) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java)
This is my Configuration function which i am calling in main init
Future<void> _configureAmplify() async {
if (!mounted) return;
Amplify.addPlugins([AmplifyStorageS3(), AmplifyAPI(), AmplifyAuthCognito()]);
if (Amplify.isConfigured == false) {
try {
await Amplify.configure(amplifyconfig);
}
on AmplifyAlreadyConfiguredException {
print("Amplify was already configured. Was the app restarted?");
}}
else {
print("Amplify was already configured. Was the app restarted?");
}}
Any sort of help will be appreciated