Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Critical] Missing implementation in Core #315

Closed
1 task done
joekendal opened this issue Jan 20, 2021 · 9 comments
Closed
1 task done

[Critical] Missing implementation in Core #315

joekendal opened this issue Jan 20, 2021 · 9 comments

Comments

@joekendal
Copy link

Describe the bug
For some reason, the Amplify Core throws a MissingPluginException as a result of this block of code

Future<bool> configure(String version, String configuration) {
  throw UnimplementedError('configure() has not been implemented.');
}

You'd think this wouldn't be the case as how could any of the plugins be working for others if there is an incomplete implementation of the core. This is the dev channel as well.

To Reproduce
Steps to reproduce the behavior:

  1. Follow the Getting Started tutorial
  2. Attempt any of the subsequent tutorials for using the plugins
  3. flutter run

Expected behavior
For the button to be active and its text to appear configured, and for an analytics event to be fired off to Pinpoint

Actual behaviour
Screenshot 2021-01-20 at 15 45 02

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
[ERROR:flutter/lib/ui/ui_dart_state.cc(184)] Unhandled Exception: MissingPluginException(No implementation found for method configure on channel com.amazonaws.amplify/core)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
<asynchronous suspension>
#1      Amplify.configure (package:amplify_core/amplify_core.dart:86:15)
<asynchronous suspension>
#2      _MyAppState._configureAmplify (package:app/main.dart:38:5)
<asynchronous suspension>

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

  • all
@joekendal joekendal changed the title Missing implementation of Core [Critical][Dev] Missing implementation in Core Jan 20, 2021
@joekendal joekendal changed the title [Critical][Dev] Missing implementation in Core [Critical] Missing implementation in Core Jan 20, 2021
@joekendal
Copy link
Author

joekendal commented Jan 20, 2021

Issue related to #274

@Ashish-Nanda
Copy link
Contributor

@joekendal what version of Amplify flutter are you using? Are you using the package locally or the published versions?

#274 talks about upcoming breaking changes, but that has not been published yet.

Can you share your app code where you are adding the plugins and calling configure? Also share your amplifyconfiguration.dart file please.

@joekendal
Copy link
Author

@Ashish-Nanda

Version: 0.0.1-dev.6 from the published version

The code is the same as the tutorial:

main.dart

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:flutter/material.dart';
import 'package:amplify_core/amplify_core.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'amplifyconfiguration.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _amplifyConfigured = false;

  // Instantiate Amplify
  Amplify amplifyInstance = Amplify();

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

  void _configureAmplify() async {
    if (!mounted) return;

    // Add Pinpoint and Cognito Plugins
    AmplifyAnalyticsPinpoint analyticsPlugin = AmplifyAnalyticsPinpoint();
    AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
    amplifyInstance.addPlugin(authPlugins: [authPlugin]);
    amplifyInstance.addPlugin(analyticsPlugins: [analyticsPlugin]);

    // Once Plugins are added, configure Amplify
    await amplifyInstance.configure(amplifyconfig);
    try {
      setState(() {
        _amplifyConfigured = true;
      });
    } catch (e) {
      print(e);
    }
  }

  // Send an event to Pinpoint
  void _recordEvent() async {
    AnalyticsEvent event = AnalyticsEvent("test");
    event.properties.addBoolProperty("boolKey", true);
    event.properties.addDoubleProperty("doubleKey", 10.0);
    event.properties.addIntProperty("intKey", 10);
    event.properties.addStringProperty("stringKey", "stringValue");
    Amplify.Analytics.recordEvent(event: event);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Amplify Core example app'),
        ),
        body: ListView(
          padding: EdgeInsets.all(10.0),
          children: <Widget>[
            Center(
              child: Column(
                children: [
                  const Padding(padding: EdgeInsets.all(5.0)),
                  Text(_amplifyConfigured ? "configured" : "not configured"),
                  RaisedButton(
                      onPressed: _amplifyConfigured ? _recordEvent : null,
                      child: const Text('record event'))
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}

amplifyconfiguration.dart

const amplifyconfig = ''' {
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "analytics": {
        "plugins": {
            "awsPinpointAnalyticsPlugin": {
                "pinpointAnalytics": {
                    "appId": my app id,
                    "region": "eu-west-1"
                },
                "pinpointTargeting": {
                    "region": "eu-west-1"
                }
            }
        }
    },
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "UserAgent": "aws-amplify-cli/0.1.0",
                "Version": "0.1.0",
                "IdentityManager": {
                    "Default": {}
                },
                "CredentialsProvider": {
                    "CognitoIdentity": {
                        "Default": {
                            "PoolId": "eu-west-2:{{ my pool id }}",
                            "Region": "eu-west-2"
                        }
                    }
                },
                "Auth": {
                    "Default": {
                        "authenticationFlowType": "USER_SRP_AUTH"
                    }
                },
                "PinpointAnalytics": {
                    "Default": {
                        "AppId": "{{ my app id }}",
                        "Region": "eu-west-1"
                    }
                },
                "PinpointTargeting": {
                    "Default": {
                        "Region": "eu-west-1"
                    }
                }
            }
        }
    }
}''';

@Ashish-Nanda
Copy link
Contributor

@joekendal could you make just a single call to amplifyInstance.addPlugin() like so:

amplifyInstance.addPlugin(
        authPlugins: [authPlugin],
        analyticsPlugins: [analyticsPlugin]);

I think calling it multiple times is the issue. Let me know if that works.

@joekendal
Copy link
Author

@Ashish-Nanda no, same issue :(

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 20, 2021

Hey @joekendal I'm looking to reproduce your issue on my machine. Could you provide your pubspec.yaml as well? I'm assuming it's just this:

  amplify_core: ^0.0.1-dev.6
  amplify_analytics_pinpoint: ^0.0.1-dev.6
  amplify_auth_cognito: ^0.0.1-dev.6

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 20, 2021

Hi @joekendal I've recreated your project copy pasting what was provided and using the above imports in pubspec.yaml

I was not able to reproduce your error, the config works fine and I'm able to send events.

Could you try running: flutter clean build?

Also, what platforms did you test on?
Are you using an emulator or a physical device?

@joekendal
Copy link
Author

@fjnoyp this seems to be an issue on desktop. shouldn't flutter packages be compatible with any flutter runtime environment? Where do I need to look in the code to fix this? Happy to try and open a PR to address if someone can give me a clue

@Amplifiyer
Copy link
Contributor

@joekendal, amplify-flutter currently only supports android and iOS environments. +1 here #133 for Desktop support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants