-
Notifications
You must be signed in to change notification settings - Fork 267
Closed
Labels
datastoreIssues related to the DataStore CategoryIssues related to the DataStore Category
Description
Bug
I am facing bug from couple of days that Tried to get a plugin before it was configured. Make sure you call Amplify.configure() first. But it is already configured before calling Amplify.Datastore.save(). and I am sure that nothing wrong with my Amplify Configuration json file because I am successfully able to add plugin of AmplifyAuthCognito and configure Amplify by that json file only to register activity of my application.
To Reproduce
import 'dart:ui';
import 'package:amplify_datastore/amplify_datastore.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:amplify_flutter/amplify.dart';
import 'package:grillhouse/Screens/Registration/login_screen.dart';
import 'amplifyconfiguration.dart';
import 'package:grillhouse/models/ModelProvider.dart';
void main() async {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
initState(){
super.initState();
_configureAmplify();
}
void _configureAmplify() async {
try {
await Amplify.addPlugin(AmplifyDataStore(modelProvider: ModelProvider.instance));
await Amplify.configure(amplifyconfig);
} catch (e) {
print("AmplifyException" + e.message);
}
final item = Todo(id: "01", name: "test");
await Amplify.DataStore.save(item);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primaryColor: Color(0xffffb525),
),
debugShowCheckedModeBanner: false,
home: LoginScreen()
);
}
}
Logs
Launching lib\main.dart on Redmi Note 5 Pro in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:50802/--qJovx-KqY=/ws
Syncing files to device Redmi Note 5 Pro...
I/mple.grillhous(18550): ProcessProfilingInfo new_methods=1015 is saved saved_to_disk=1 resolve_classes_delay=8000
D/AWSMobileClient(18550): Inspecting user state details
W/mple.grillhous(18550): Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (light greylist, reflection)
I/flutter (18550): AmplifyExceptionUnable to read appId or region from the amplify configuration json.
E/MethodChannel#com.amazonaws.amplify/datastore(18550): Failed to handle method call
E/MethodChannel#com.amazonaws.amplify/datastore(18550): java.lang.IllegalStateException: Tried to get a plugin before it was configured. Make sure you call Amplify.configure() first.
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at com.amplifyframework.core.category.Category.getPluginIfConfiguredOrThrow(Category.java:239)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at com.amplifyframework.core.category.Category.getPlugin(Category.java:186)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.onSave(AmplifyDataStorePlugin.kt:272)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.onMethodCall(AmplifyDataStorePlugin.kt:107)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at android.os.Looper.loop(Looper.java:165)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at android.app.ActivityThread.main(ActivityThread.java:6810)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/MethodChannel#com.amazonaws.amplify/datastore(18550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
E/flutter (18550): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: DataStoreException(message: An unknown exception has happened. Please take a look at
E/flutter (18550): https://github.com/aws-amplify/amplify-flutter/issues to see if there are any existing issues that
E/flutter (18550): match your scenario, and file an issue with the details of the bug if there isn't.
E/flutter (18550): , recoverySuggestion: We currently don't have a recovery suggestion for this exception., underlyingException: PlatformException(error, Tried to get a plugin before it was configured. Make sure you call Amplify.configure() first., null, java.lang.IllegalStateException: Tried to get a plugin before it was configured. Make sure you call Amplify.configure() first.
E/flutter (18550): at com.amplifyframework.core.category.Category.getPluginIfConfiguredOrThrow(Category.java:239)
E/flutter (18550): at com.amplifyframework.core.category.Category.getPlugin(Category.java:186)
E/flutter (18550): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.onSave(AmplifyDataStorePlugin.kt:272)
E/flutter (18550): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.onMethodCall(AmplifyDataStorePlugin.kt:107)
E/flutter (18550): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (18550): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (18550): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter (18550): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (18550): at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter (18550): at android.os.Looper.loop(Looper.java:165)
E/flutter (18550): at android.app.ActivityThread.main(ActivityThread.java:6810)
E/flutter (18550): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (18550): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/flutter (18550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
E/flutter (18550): ))
E/flutter (18550): #0 AmplifyDataStoreMethodChannel.save (package:amplify_datastore/method_channel_datastore.dart:105:7)
E/flutter (18550): <asynchronous suspension>
E/flutter (18550): #1 _MyAppState._configureAmplify (package:grillhouse/main.dart:35:7)
E/flutter (18550): <asynchronous suspension>
E/flutter (18550):
Platform
[1] Android
Metadata
Metadata
Assignees
Labels
datastoreIssues related to the DataStore CategoryIssues related to the DataStore Category
