Ошибка Amplify Flutter «handleWebUISignInResponse не поддерживается» после входа в GoogleAndroid

Форум для тех, кто программирует под Android
Anonymous
Ошибка Amplify Flutter «handleWebUISignInResponse не поддерживается» после входа в Google

Сообщение Anonymous »

Ошибка java.lang.IllegalStateException: handleWebUISignInResponse не поддерживается выдается после успешного входа в Google в мое приложение Amplify с использованием веб-представления AmplifyAuthCognito. Это приводит к сбою приложения сразу после успешного входа в систему, и следующее действие не отображается.
Я думаю, что мои сервисы AWS настроены правильно, поскольку вход в систему работает.
Все необходимые дополнения есть в файле AndroidManifest.xml: и pubspec.yaml:

Код: Выделить всё

  amplify_flutter: ^2.2.0
amplify_auth_cognito: ^2.2.0
amplify_authenticator: ^2.1.0
amplify_api: ^2.2.0
amplify_datastore: ^2.2.1
amplify_analytics_pinpoint: ^2.2.0
main.dart:

Код: Выделить всё

class _MyHomePageState extends State {
Future _configureAmplify() async {
if (!Amplify.isConfigured) {
try {
await Amplify.addPlugins([AmplifyAuthCognito(),
AmplifyDataStore(modelProvider: ModelProvider.instance),
AmplifyAPI()]);
await Amplify.configure(amplifyconfig);
safePrint("Initialized Amplify.");
} on Exception catch (e) {
safePrint('An error occurred configuring Amplify: $e');
}
}
}

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

@override
Widget build(BuildContext context) {
return const AuthenticatorWithOnboarding();
}
}
authenticator_with_onboarding.dart:

Код: Выделить всё

class AuthenticatorWithOnboarding extends StatelessWidget {
const AuthenticatorWithOnboarding({super.key});

@override
Widget build(BuildContext context) {
return Authenticator(
// Sets the initial step to "onboarding" to display the onboarding
// screen on app launch
initialStep: AuthenticatorStep.onboarding,

// If a builder method is provided the authenticator will
// use this to build the authenticator based on the current state.
//
// This example only customizes the onboarding step.  All other steps
// will fallback to the prebuilt authenticator
authenticatorBuilder: (context, state) {
switch (state.currentStep) {
case AuthenticatorStep.onboarding:
return OnboardingView(
navigateToSignIn: () => state.changeStep(
AuthenticatorStep.signIn,
),
navigateToSignUp: () => state.changeStep(
AuthenticatorStep.signUp,
),
);
default:
// returning null will default to the prebuilt authenticator for
// all steps other than onboarding
return null;
}
},
child: MaterialApp(
theme: ThemeData.light(useMaterial3: true),
darkTheme: ThemeData.dark(useMaterial3: true),
themeMode: ThemeMode.system,
debugShowCheckedModeBanner: false,
builder: Authenticator.builder(),
initialRoute: '/routeA',
routes: {
'/routeA': (BuildContext context) => const ChartsDemo(),
'/routeB': (BuildContext context) => const FeaturesDemo(),
},
),
);
}
}

// An onboarding widget to display to unauthenticated users on initial app launch
class OnboardingView extends StatelessWidget {
const OnboardingView({
super.key,
required this.navigateToSignIn,
required this.navigateToSignUp,
});

final void Function() navigateToSignIn;
final void Function() navigateToSignUp;

@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
const FlutterLogo(size: 200),
const SizedBox(height: 32),
Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '
'Pellentesque faucibus viverra vehicula. In iaculis augue non '
'lacinia imperdiet. Aenean tempor mi nec condimentum posuere.',
style: Theme.of(context).textTheme.titleMedium,
),
const Spacer(),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: navigateToSignUp,
child: const Text('Get Started'),
),
),
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: navigateToSignIn,
child: const Text('Sign In'),
),
),
],
),
),
);
}
}
Журнал ошибок:

Код: Выделить всё

E/AndroidRuntime(15233): Caused by: java.lang.IllegalStateException: handleWebUISignInResponse is not supported
E/AndroidRuntime(15233):    at com.amazonaws.amplify.amplify_datastore.NativeAuthPluginWrapper.unsupported(NativeAuthPluginWrapper.kt:415)
E/AndroidRuntime(15233):    at com.amazonaws.amplify.amplify_datastore.NativeAuthPluginWrapper.handleWebUISignInResponse(NativeAuthPluginWrapper.kt:258)
E/AndroidRuntime(15233):    at com.amplifyframework.auth.AuthCategory.handleWebUISignInResponse(AuthCategory.java:196)
E/AndroidRuntime(15233):    at com.amplifyframework.auth.cognito.activities.HostedUIRedirectActivity.onResume(HostedUIRedirectActivity.kt:41)
E/AndroidRuntime(15233):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1603)
E/AndroidRuntime(15233):    at android.app.Activity.performResume(Activity.java:9134)
E/AndroidRuntime(15233):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5399)
E/AndroidRuntime(15233):    ... 13 more
Таким образом, кажется, что он использует это действие: https://github.com/aws-amplify/amplify- ... d/src/main /kotlin/com/amazonaws/amplify/amplify_datastore/NativeAuthPluginWrapper.kt
Это действие не реализует handleWebUISignInResponse. Какую активность должно использовать приложение?
В чем может быть проблема? Спасибо.

Подробнее здесь: https://stackoverflow.com/questions/787 ... ter-google

Вернуться в «Android»