Repository navigation
[google_sign_in] Failed to launch the selector UI. Hint: ensure the context parameter is an Activity-based context. #171122
Copy link
Copy link
Closed
flutter/packages
#9497Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listfyi-androidFor the attention of Android platform teamFor the attention of Android platform teamp: google_sign_inThe Google Sign-In pluginThe Google Sign-In pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
What package does this bug report belong to?
google_sign_in
What target platforms are you seeing this bug on?
Android
Have you already upgraded your packages?
Yes
Dependency versions
pubspec.lock
google_sign_in:
dependency: "direct main"
description:
name: google_sign_in
sha256: dba1a1a79368d8ca464bf36ef94f528851efa9925e4a28bfc4aaefb1f5da2fc4
url: "https://pub.dev"
source: hosted
version: "7.0.0"
google_sign_in_android:
dependency: transitive
description:
name: google_sign_in_android
sha256: ac7cfb8216dc34d18221cc4ec9e0a07346a00420a37c548d151ac8ad49df0d7b
url: "https://pub.dev"
source: hosted
version: "7.0.0"
google_sign_in_ios:
dependency: transitive
description:
name: google_sign_in_ios
sha256: "59937a674827540d12253415626ec24cc7e633bb785e2d2ca4f1580323e55a0c"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
google_sign_in_platform_interface:
dependency: transitive
description:
name: google_sign_in_platform_interface
sha256: "8736443134d2cccadd4f228d600177cb3947e36683466a6ab96877ce6932885a"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
google_sign_in_web:
dependency: transitive
description:
name: google_sign_in_web
sha256: "09ac306b2787b48f19c857b9f93375b654f774643c75bd6a1a078c85f4f7b468"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
Steps to reproduce
1 install dependencie google_sign_in: ^7.0.0
2 create page
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
class LogInView extends StatefulWidget {
const LogInView({super.key});
@override
State<LogInView> createState() => _LogInViewState();
}
class _LogInViewState extends State<LogInView> {
final List<String> scopes = <String>[];
GoogleSignInAccount? _currentUser;
Future<void> _handleAuthenticationEvent(GoogleSignInAuthenticationEvent event) async {
// #docregion CheckAuthorization
final GoogleSignInAccount? user = // ...
// #enddocregion CheckAuthorization
switch (event) {
GoogleSignInAuthenticationEventSignIn() => event.user,
GoogleSignInAuthenticationEventSignOut() => null,
};
setState(() {
_currentUser = user;
});
// If the user has already granted access to the required scopes, call the
// REST API.
}
Future<void> _handleAuthenticationError(Object e) async {
print(e);
}
@override
void initState() {
super.initState();
// #docregion Setup
final GoogleSignIn signIn = GoogleSignIn.instance;
unawaited(
signIn
.initialize(
clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxx',
serverClientId: 'xxxxxxxxxxxxxx',
)
.then((_) {
signIn.authenticationEvents.listen(_handleAuthenticationEvent).onError(_handleAuthenticationError);
}),
);
// #enddocregion Setup
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: InkWell(
child: Text('Login'),
onTap: () async {
try {
await GoogleSignIn.instance.authenticate();
} catch (e) {
// #enddocregion ExplicitSignIn
print(e);
// #docregion ExplicitSignIn
}
},
),
),
);
}
}
3 remplace
clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
serverClientId: 'xxxxxxxxxxxxxx'
4 clic in Login
Expected results
start with the Google login process
Actual results
get error
code: 11417212
Failed to launch the selector UI. Hint: ensure the context parameter is an Activity-based context.
Code sample
Code sample
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
class LogInView extends StatefulWidget {
const LogInView({super.key});
@override
State<LogInView> createState() => _LogInViewState();
}
class _LogInViewState extends State<LogInView> {
final List<String> scopes = <String>[];
GoogleSignInAccount? _currentUser;
Future<void> _handleAuthenticationEvent(GoogleSignInAuthenticationEvent event) async {
// #docregion CheckAuthorization
final GoogleSignInAccount? user = // ...
// #enddocregion CheckAuthorization
switch (event) {
GoogleSignInAuthenticationEventSignIn() => event.user,
GoogleSignInAuthenticationEventSignOut() => null,
};
setState(() {
_currentUser = user;
});
// If the user has already granted access to the required scopes, call the
// REST API.
}
Future<void> _handleAuthenticationError(Object e) async {
print(e);
}
@override
void initState() {
super.initState();
// #docregion Setup
final GoogleSignIn signIn = GoogleSignIn.instance;
unawaited(
signIn
.initialize(
clientId: 'xxxxxxxxxxxxxxxxxxxxxxxxx',
serverClientId: 'xxxxxxxxxxxxxx',
)
.then((_) {
signIn.authenticationEvents.listen(_handleAuthenticationEvent).onError(_handleAuthenticationError);
}),
);
// #enddocregion Setup
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: InkWell(
child: Text('Login'),
onTap: () async {
try {
await GoogleSignIn.instance.authenticate();
} catch (e) {
// #enddocregion ExplicitSignIn
print(e);
// #docregion ExplicitSignIn
}
},
),
),
);
}
}Screenshots or Videos
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
GoogleSignInException(code GoogleSignInExceptionCode.unknownError, Failed to launch the selector UI. Hint: ensure the `context` parameter is an Activity-based context., null)Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.32.4, on Ubuntu 24.04.2 LTS 6.11.0-26-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
! Unable to access driver information using 'eglinfo'.
It is likely available from your distribution (e.g.: apt install mesa-utils)
[✓] Android Studio (version 2024.3)
[✓] VS Code (version unknown)
✗ Unable to determine VS Code version.
[✓] Connected device (3 available)
[✓] Network resourcesReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listfyi-androidFor the attention of Android platform teamFor the attention of Android platform teamp: google_sign_inThe Google Sign-In pluginThe Google Sign-In pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyAndroid applications specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Activity
[-]Failed to launch the selector UI. Hint: ensure the `context` parameter is an Activity-based context.[/-][+][google_sign_in] Failed to launch the selector UI. Hint: ensure the `context` parameter is an Activity-based context.[/+]pavkoccino commentedon Jun 25, 2025
jhonessds commentedon Jun 25, 2025
yocheco commentedon Jun 25, 2025
The issue is that version 6.x relies on Google’s deprecated login SDK. I’m currently updating from 6.x to 7.x, and while everything works fine on 6.x, I want to move forward since that SDK is no longer supported.
stuartmorgan-g commentedon Jun 25, 2025
It looks like this should be relatively straightforward to fix. It's not clear to my this didn't show up in my testing though, so once I have a PR I'll post instructions on testing it; it would be good to have validation that the fix is complete before landing it.
yocheco commentedon Jun 25, 2025
Thanks! If you share a PR or test instructions, I’ll be happy to try it out and confirm whether the issue is resolved on my side.
stuartmorgan-g commentedon Jun 25, 2025
@yocheco (and anyone else interested in trying the fix), adding the following to your pubspec.yaml and running
flutter pub getshould pick up the change that I expect to fix this.Be sure not to leave this in your pubspec.yaml, as it will prevent getting any future fixes to the Android implementation of
google_sign_in.2 remaining items
pongloongyeat commentedon Jun 26, 2025
Distantman commentedon Jun 26, 2025
[google_sign_in] Use an activity for credential requests (#9497)
stuartmorgan-g commentedon Jun 26, 2025
flutter pub upgrade --unlock-transitive google_sign_inshould pick up the fixed version ofgoogle_sign_in_android.jaybe78 commentedon Jun 26, 2025
Thanks @stuartmorgan-g This solves the problem
pongloongyeat commentedon Jun 28, 2025
stuartmorgan-g commentedon Jun 28, 2025
The way to report an issue is to file a new issue, not to comment about it in a completely unrelated issue.
github-actions commentedon Jul 12, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[google_sign_in] Use an activity for credential requests (flutter#9497)
[google_sign_in] Use an activity for credential requests (flutter#9497)
[google_sign_in] Use an activity for credential requests (flutter#9497)