1

我正在尝试将 AWS Amplify 的 AmplifyStorageS3、AmplifyAPI 和 AmplifyAuthCognito 与我的颤振应用程序一起使用。我按照文档进行操作,一切正常,但有时应用程序在 Android 10 上崩溃并出现以下错误

致命异常:java.lang.IllegalStateException:试图在配置之前获取插件。确保首先调用 Amplify.configure()。在 com.amplifyframework.core.category.Category.getPluginIfConfiguredOrThrow(Category.java:75) 在 com.amplifyframework.core.category.Category.getSelectedPlugin(Category.java:31) 在 com.amplifyframework.api.ApiCategory.query(ApiCategory .java) 在 com.amazonaws.amplify.amplify_api.FlutterGraphQLApi$query$2.invokeSuspend(FlutterGraphQLApi.java:61) 在 kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:9) 在 kotlinx.coroutines.DispatchedTask .run(DispatchedTask.java:94) 在 kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java) 在 kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:14) 在 kotlinx.coroutines。

这是我在 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?");
}}

任何形式的帮助将不胜感激

4

0 回答 0