amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

Platform exception when initializing

Open mattRiddoch opened this issue 6 years ago • 2 comments

Describe the bug When running the app await amplifyInstance.configure(amplifyconfig); raises this error: PlatformException (PlatformException(AmplifyException, Failed to Configure Amplify, The operation couldn’t be completed. (Amplify.PluginError error 2.), null)) To Reproduce Steps to reproduce the behavior:

  1. Follow docs starting here: https://docs.amplify.aws/lib/project-setup/create-application/q/platform/flutter
  2. Run app.
  3. Raise exception.

Expected behavior App to complete configuration error free amplifyconfiguration.dart created without issues

Platform Amplify Flutter current supports iOS and Android. This issue is reproducable in (check all that apply): [] Android [x] iOS

Smartphone (please complete the following information):

  • Device: Simulator 11 Pro
  • OS: iOS 13.6

Additional context pubspec.yaml:

amplify_core: '<1.0.0'
amplify_auth_cognito: '<1.0.0'
amplify_storage_s3: '<1.0.0'
amplify_analytics_pinpoint: '<1.0.0'

main.dart:

imports... (in app state)

Amplify amplifyInstance = Amplify();
 @override
 void initState() {
   super.initState();
   _configureAmplify();
 }

 void _configureAmplify() async {
   AmplifyAnalyticsPinpoint analyticsPlugin = AmplifyAnalyticsPinpoint();
   AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
   amplifyInstance.addPlugin(authPlugins: [authPlugin]);
   amplifyInstance.addPlugin(analyticsPlugins: [analyticsPlugin]);
   await amplifyInstance.configure(amplifyconfig);//<-- Error Here!!
 }

amplifyconfiguration.dart:

const amplifyconfig = ''' {
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify-cli/0.1.0",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "...",
                            "Region": "us-east-1"
                        }
                    }
                },
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "us-east-1_BIv5TRO9E",
                        "AppClientId": "...",
                        "AppClientSecret": "...",
                        "Region": "us-east-1"
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH"
                    }
                },
                "PinpointAnalytics": {
                    "Default": {
                        "AppId": "...",
                        "Region": "us-east-1"
                    }
                },
                "PinpointTargeting": {
                    "Default": {
                        "Region": "us-east-1"
                    }
                }
            }
        }
    },
    "analytics": {
        "plugins": {
            "awsPinpointAnalyticsPlugin": {
                "pinpointAnalytics": {
                    "appId": "...",
                    "region": "us-east-1"
                },
                "pinpointTargeting": {
                    "region": "us-east-1"
                }
            }
        }
    }
}''';

mattRiddoch avatar Aug 26 '20 04:08 mattRiddoch

Hi @mattRiddoch

Could you try removing the storage dependency you have in your pubspec.yaml?

It is possible the configure call is failing since you do not have any storage config in your amplifyconfiguration.dart. That is also where your code differs from the docs setup steps.

Please run a flutter clean and then flutter run after as well.

Ashish-Nanda avatar Aug 26 '20 16:08 Ashish-Nanda

Yeah removing the storage dependency did the trick! I will take the liberty of closing this out.

mattRiddoch avatar Aug 26 '20 16:08 mattRiddoch