Closed sahinthomas closed 2 years ago
When i run the code for login, It Just returns LoginStatus.failed as response. A window is started to open, and suddenly it closes.
Hi what is the message returned by the LoginResult instance?
Hi I were trying with version 3.4.1
, also facing the same issue as above with the message:
Unexpected call to LoginManager.onActivityResult
Many thanks for your quick response @darwin-morocho ;-)
Hi I were trying with version
3.4.1
, also facing the same issue as above with the message:Unexpected call to LoginManager.onActivityResult
Many thanks for your quick response @darwin-morocho ;-)
please follow the issue template that help me to identifier the problem
In the most cases the error is due to a bad hash code because you are on windows or a bad configuration in your facebook console
When i run the code for login, It Just returns LoginStatus.failed as response. A window is started to open, and suddenly it closes.
Hi what is the message returned by the LoginResult instance?
LoginStatus.failed
When i run the code for login, It Just returns LoginStatus.failed as response. A window is started to open, and suddenly it closes.
Hi what is the message returned by the LoginResult instance?
LoginStatus.failed
the LoginResult class has a field called message. Please add the message
When i run the code for login, It Just returns LoginStatus.failed as response. A window is started to open, and suddenly it closes.
Hi what is the message returned by the LoginResult instance?
LoginStatus.failed
the LoginResult class has a field called message. Please add the message
Unexpected call to LoginManager.onActivityResult
When i run the code for login, It Just returns LoginStatus.failed as response. A window is started to open, and suddenly it closes.
Hi what is the message returned by the LoginResult instance?
LoginStatus.failed
the LoginResult class has a field called message. Please add the message
Unexpected call to LoginManager.onActivityResult
Please follow the issue template
hi, I had this issue and face the same error this my code to login
Future
if (result.status != LoginStatus.success) {
// Create a credential from the access token
final firebase_auth.OAuthCredential credential =
firebase_auth.FacebookAuthProvider.credential(
result.accessToken.token);
// Once signed in, return the UserCredential
final firebase_auth.UserCredential userCredential =
await _firebaseAuth.signInWithCredential(credential);
}
} on Exception {
throw LogInWithFacebookFailure();
}
}
and this from debug
this = {AuthenticationRepository} _cache = {CacheClient} _firebaseAuth = {FirebaseAuth} FirebaseAuth(app: [DEFAULT]) _googleSignIn = {GoogleSignIn} _facebookAuth = {FacebookAuth} result = {LoginResult} status = {LoginStatus} LoginStatus.failed index = 2 _name = "LoginStatus.failed" message = "Unexpected call to LoginManager.onActivityResult" accessToken = null
hi, I had this issue and face the same error this my code to login
Future logInWithFacebook() async { try { final LoginResult result = await _facebookAuth.login();
if (result.status != LoginStatus.success) { // Create a credential from the access token final firebase_auth.OAuthCredential credential = firebase_auth.FacebookAuthProvider.credential( result.accessToken.token); // Once signed in, return the UserCredential final firebase_auth.UserCredential userCredential = await _firebaseAuth.signInWithCredential(credential); } } on Exception { throw LogInWithFacebookFailure(); }
}
and this from debug
this = {AuthenticationRepository} _cache = {CacheClient} _firebaseAuth = {FirebaseAuth} FirebaseAuth(app: [DEFAULT]) _googleSignIn = {GoogleSignIn} _facebookAuth = {FacebookAuth} result = {LoginResult} status = {LoginStatus} LoginStatus.failed index = 2 _name = "LoginStatus.failed" message = "Unexpected call to LoginManager.onActivityResult" accessToken = null
Why result.status != LoginStatus.success?
Here you have the issue template
Describe the bug A clear and concise description of what the bug is.
Environment
Add your flutter doctor -v
Add your pubspec.yaml
Add your Info.plist
Add your AndroidManifest.xml
Add your /app/res/values/strings.xml
To Reproduce Please add your code to reproduce the issue
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots or videos to help explain your problem.
My app show facebook login dialog but not do thing
this my flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8) • Flutter version 2.2.1 at /home/ahmed/flutter • Framework revision 02c026b03c (13 days ago), 2021-05-27 12:24:44 -0700 • Engine revision 0fdb562ac8 • Dart version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /home/ahmed/Android/Sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /home/ahmed/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821) • All Android licenses accepted.
[✓] Chrome - develop for the web • Chrome at google-chrome
[✓] Android Studio (version 4.2) • Android Studio at /home/ahmed/android-studio • Flutter plugin version 57.0.2 • Dart plugin version 202.8488 • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821)
[✓] Connected device (2 available) • Lenovo A7020a48 (mobile) • S8ROAMI74S5PL76S • android-arm64 • Android 6.0 (API 23) • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77
• No issues found!
my pubspec.yaml
name: authentication_repository description: Dart package which manages the authentication domain. version: 1.0.0 publish_to: none
environment: sdk: ">=2.7.0 <3.0.0"
dependencies: flutter: sdk: flutter cache: path: ../cache equatable: ^2.0.0 firebase_auth: ^1.3.0 firebase_core: ^1.2.1 google_sign_in: ^5.0.4 flutter_facebook_auth: ^3.4.1 meta: ^1.3.0 very_good_analysis: ^2.1.0
dev_dependencies: flutter_test: sdk: flutter mocktail: ^0.1.1
my mainfest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.flutter_firebase_login">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="flutter_firebase_login"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
my strings.xml
my code method
Future
if (result.status != LoginStatus.success) {
// Create a credential from the access token
final firebase_auth.OAuthCredential credential =
firebase_auth.FacebookAuthProvider.credential(
result.accessToken.token);
// Once signed in, return the UserCredential
final firebase_auth.UserCredential userCredential =
await _firebaseAuth.signInWithCredential(credential);
}
} on Exception {
throw LogInWithFacebookFailure();
}
}
I expect my app to login to facebook and authenticate with firebase
My app show facebook login dialog but not do thing
this my flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8) • Flutter version 2.2.1 at /home/ahmed/flutter • Framework revision 02c026b03c (13 days ago), 2021-05-27 12:24:44 -0700 • Engine revision 0fdb562ac8 • Dart version 2.13.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /home/ahmed/Android/Sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /home/ahmed/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821) • All Android licenses accepted.
[✓] Chrome - develop for the web • Chrome at google-chrome
[✓] Android Studio (version 4.2) • Android Studio at /home/ahmed/android-studio • Flutter plugin version 57.0.2 • Dart plugin version 202.8488 • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821)
[✓] Connected device (2 available) • Lenovo A7020a48 (mobile) • S8ROAMI74S5PL76S • android-arm64 • Android 6.0 (API 23) • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.77
• No issues found!
my pubspec.yaml
name: authentication_repository description: Dart package which manages the authentication domain. version: 1.0.0 publish_to: none
environment: sdk: ">=2.7.0 <3.0.0"
dependencies: flutter: sdk: flutter cache: path: ../cache equatable: ^2.0.0 firebase_auth: ^1.3.0 firebase_core: ^1.2.1 google_sign_in: ^5.0.4 flutter_facebook_auth: ^3.4.1 meta: ^1.3.0 very_good_analysis: ^2.1.0
dev_dependencies: flutter_test: sdk: flutter mocktail: ^0.1.1
my mainfest.xml
<uses-permission android:name="android.permission.INTERNET"/> <application android:label="flutter_firebase_login" android:icon="@mipmap/ic_launcher"> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" /> <activity android:name="com.facebook.CustomTabActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="@string/fb_login_protocol_scheme" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> <!-- Displays an Android View that continues showing the launch screen Drawable until Flutter paints its first frame, then this splash screen fades out. A splash screen is useful to avoid any visual gap between the end of Android's launch screen and the painting of Flutter's first frame. --> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" /> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> <meta-data android:name="flutterEmbedding" android:value="2" /> </application>
my strings.xml
Flutter Facebook Auth Example myAppId fbProtocol my code method
Future logInWithFacebook() async { try { final LoginResult result = await _facebookAuth.login();
if (result.status != LoginStatus.success) { // Create a credential from the access token final firebase_auth.OAuthCredential credential = firebase_auth.FacebookAuthProvider.credential( result.accessToken.token); // Once signed in, return the UserCredential final firebase_auth.UserCredential userCredential = await _firebaseAuth.signInWithCredential(credential); } } on Exception { throw LogInWithFacebookFailure(); }
}
I expect my app to login to facebook and authenticate with firebase
Your project is using dart >=2.7.0 so you must not have null safety dependencies. All dependencies in your pubspec.yaml are designed for dart >=2.12.0 you must use version before null safety
@A7mdFathi , @sahinthomas , @thainguyen-fika after check the problem seems to be the facebook sdk for some reason is not returned data the first time login. I've tested with a native project and I have the same problem.
I've opened an issue in the android facebook sdk repo https://github.com/facebook/facebook-android-sdk/issues/968
thanks for your great effort @darwin-morocho , let's hope this will be solved soonly.
@A7mdFathi , @sahinthomas , @thainguyen-fika after check the problem seems to be the facebook sdk for some reason is not returned data the first time login. I've tested with a native project and I have the same problem.
I've opened an issue in the android facebook sdk repo facebook/facebook-android-sdk#968
Ohh, Thanks for your effort. @darwin-morocho
The problem seems to be the Facebook app on Android if you use the loginBehavior param and use LoginBehavior.webOnly it works
Thanks for your effort @darwin-morocho I hope they will solve this soon
LoginBehavior.webOnly
Thank you
Describe the bug
My app show facebook login dialog but not do thing
error logs
Unexpected call to LoginManager.onActivityResult
Environment
this is my flutter doctor -v
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.19041.985], locale en-US)
• Flutter version 1.22.6 at C:\Mirza\Flutter\flutter
• Framework revision 9b2d32b605 (5 months ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\User\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.56.2)
• VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.23.0`
Add your `pubspec.yaml
name: appName
description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
google_fonts: ^1.1.2
flutter_svg: ^0.19.0
email_validator: ^1.0.6
circular_check_box: ^1.0.4
fluttertoast: ^7.1.6
provider: ^4.3.2+3
geocoding: ^1.0.5
geolocator: ^6.1.13
dotted_border: ^1.0.7
pin_code_fields: ^6.1.0
qr_code_scanner: ^0.3.0
flutter_multi_formatter: ^1.3.3
dio: ^3.0.10
get_it: ^5.0.6
device_info: ^1.0.0
flutter_google_places: ^0.2.6
location: ^3.0.0
google_maps_flutter: ^1.0.6
firebase_database: ^4.4.0
firebase_storage: ^5.2.0
firebase_core: ^0.5.3
cloud_firestore: ^0.14.4
firebase_messaging: ^7.0.3
flutter_local_notifications: ^4.0.1+2
shared_preferences: ^0.5.12+4
image_picker: ^0.6.7+21
photo_view: ^0.10.3
image_cropper: ^1.3.1
url_launcher: ^5.7.2
stripe_payment: ^1.0.11
maps_launcher: ^1.2.2+2
lottie: ^0.7.0+1
flutter_inappwebview: ^4.0.0+4
firebase_crashlytics: ^0.2.4
flutter_launcher_icons: ^0.8.1
google_sign_in: ^4.5.9
sign_in_with_apple: ^2.5.4
http: ^0.12.2
flutter_facebook_login: ^3.0.0
flutter_facebook_auth: ^3.0.0
dev_dependencies:
change_app_package_name:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
flutter_icons:
image_path: "assets/icon/appicon.png"
android: true
ios: true
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/
- assets/lottie/
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
Add your Info.plist
Add your AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.me.packagename">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" tools:node="replace" />
<application
android:name=".Application"
android:label="Project Name"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon_push" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@android:color/transparent" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="high_importance_channel" />
<!-- Currently using the butlers project key -->
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="API_KEY"/>
<!-- Facebook Login configuration -->
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="Rimattire"
android:exported="true"
/>
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
Add your /app/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="facebook_app_id">12345</string>
<string name="fb_login_protocol_scheme">fb12345</string>
</resources>
**To Reproduce**
signInWithFacebook() async {
final LoginResult result = await FacebookAuth.instance.login(
permissions: ['public_profile', 'email'],
);
if (result.status == LoginStatus.success) {
var profile =
getUserFacebookProfileThroughGraphApi(result.accessToken.token);
print(profile.toString());
} else if (result.status == LoginStatus.cancelled) {
print(result.message);
} else if (result.status == LoginStatus.failed) {
print(result.message);
} else if (result.status == LoginStatus.operationInProgress) {
print(result.message);
}
// by default we request the email and the public profile
}
Future<dynamic> getUserFacebookProfileThroughGraphApi(
String accessToken) async {
var graphResponse = await serviceLocatorInstance<DioApiServices>().getRequest(
'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=' +
accessToken);
return graphResponse;
}
Expected behavior I expect my app to login to facebook and authenticate with firebase
Screenshots If applicable, add screenshots or videos to help explain your problem.
Describe the bug My app show facebook login dialog but not do thing error logs Unexpected call to LoginManager.onActivityResult Environment this is my
flutter doctor -v
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.19041.985], locale en-US) • Flutter version 1.22.6 at C:\Mirza\Flutter\flutter • Framework revision 9b2d32b605 (5 months ago), 2021-01-22 14:36:39 -0800 • Engine revision 2f0af37152 • Dart version 2.10.5 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\User\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [!] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio X Flutter plugin not installed; this adds Flutter specific functionality. X Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [√] VS Code (version 1.56.2) • VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.23.0`
Add your `pubspec.yaml
name: appName description: A new Flutter application. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.7.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.0 google_fonts: ^1.1.2 flutter_svg: ^0.19.0 email_validator: ^1.0.6 circular_check_box: ^1.0.4 fluttertoast: ^7.1.6 provider: ^4.3.2+3 geocoding: ^1.0.5 geolocator: ^6.1.13 dotted_border: ^1.0.7 pin_code_fields: ^6.1.0 qr_code_scanner: ^0.3.0 flutter_multi_formatter: ^1.3.3 dio: ^3.0.10 get_it: ^5.0.6 device_info: ^1.0.0 flutter_google_places: ^0.2.6 location: ^3.0.0 google_maps_flutter: ^1.0.6 firebase_database: ^4.4.0 firebase_storage: ^5.2.0 firebase_core: ^0.5.3 cloud_firestore: ^0.14.4 firebase_messaging: ^7.0.3 flutter_local_notifications: ^4.0.1+2 shared_preferences: ^0.5.12+4 image_picker: ^0.6.7+21 photo_view: ^0.10.3 image_cropper: ^1.3.1 url_launcher: ^5.7.2 stripe_payment: ^1.0.11 maps_launcher: ^1.2.2+2 lottie: ^0.7.0+1 flutter_inappwebview: ^4.0.0+4 firebase_crashlytics: ^0.2.4 flutter_launcher_icons: ^0.8.1 google_sign_in: ^4.5.9 sign_in_with_apple: ^2.5.4 http: ^0.12.2 flutter_facebook_login: ^3.0.0 flutter_facebook_auth: ^3.0.0 dev_dependencies: change_app_package_name: flutter_test: sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec flutter_icons: image_path: "assets/icon/appicon.png" android: true ios: true # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: assets: - assets/ - assets/lottie/ # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages
Add your
Info.plist
Add yourAndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.weuno.rimattire"> <!-- io.flutter.app.FlutterApplication is an android.app.Application that calls FlutterMain.startInitialization(this); in its onCreate method. In most cases you can leave this as-is, but you if you want to provide additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WAKE_LOCK" tools:node="replace" /> <application android:name=".Application" android:label="Rimattire" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="true" > <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> <!-- Displays an Android View that continues showing the launch screen Drawable until Flutter paints its first frame, then this splash screen fades out. A splash screen is useful to avoid any visual gap between the end of Android's launch screen and the painting of Flutter's first frame. --> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" /> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <intent-filter> <action android:name="FLUTTER_NOTIFICATION_CLICK" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon_push" /> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@android:color/transparent" /> <activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.NoActionBar"/> <!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> <meta-data android:name="flutterEmbedding" android:value="2" /> <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="high_importance_channel" /> <!-- Currently using the butlers project key --> <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDqZwFywKfU1-mw25YEGRCF1_Ywy_7yKXk"/> <!-- Facebook Login configuration --> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="Rimattire" android:exported="true" /> <activity android:name="com.facebook.CustomTabActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="@string/fb_login_protocol_scheme" /> </intent-filter> </activity> </application> </manifest>
Add your
/app/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="facebook_app_id">12345</string> <string name="fb_login_protocol_scheme">fb12345</string> </resources> **To Reproduce**
signInWithFacebook() async { final LoginResult result = await FacebookAuth.instance.login( permissions: ['public_profile', 'email'], ); if (result.status == LoginStatus.success) { var profile = getUserFacebookProfileThroughGraphApi(result.accessToken.token); print(profile.toString()); } else if (result.status == LoginStatus.cancelled) { print(result.message); } else if (result.status == LoginStatus.failed) { print(result.message); } else if (result.status == LoginStatus.operationInProgress) { print(result.message); } // by default we request the email and the public profile } Future<dynamic> getUserFacebookProfileThroughGraphApi( String accessToken) async { var graphResponse = await serviceLocatorInstance<DioApiServices>().getRequest( 'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=' + accessToken); return graphResponse; }
Expected behavior I expect my app to login to facebook and authenticate with firebase
Screenshots If applicable, add screenshots or videos to help explain your problem.
Hi you should use flutter_facebook_auth: ^3.3.3-no-nullsafety
because your project doesn't use null safety. Also the problem seems to be the facebook app.
Here we have more info about the issue with the facebook app https://developers.facebook.com/support/bugs/960815398044810/
The facebook developer team says the issue was solved
When i run the code for login, It Just returns LoginStatus.failed as response. A window is started to open, and suddenly it closes.