flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [flutterfire_ui] 'sign in with google' button crash the application on IOS

Open nebarkay opened this issue 1 year ago • 5 comments

Bug report

When using builtin 'sign in with google' button on IOS (15.5) the application crash. On android the button works. If I build a button with 'google_sign_in: ^5.4.0' the sign works (so it's not a problem of settings).

Steps to reproduce

Steps to reproduce the behavior:

  1. run the code
  2. press 'sign in with google'
  3. application crash!

Expected behavior

I expect to login to google.

Sample project

return MaterialApp(
      initialRoute: auth.currentUser == null ? '/' : '/profile',
      routes: {
        '/': (context) {
          return SignInScreen(
            providerConfigs: const [
              GoogleProviderConfiguration(clientId: ""),
            ],
            // no providerConfigs property - global configuration will be used instead
            actions: [
              AuthStateChangeAction<SignedIn>((context, state) {
                const Text('you are logged in');
              }),
            ],
          );
        },
        '/profile': (context) {
          return ProfileScreen(
            // no providerConfigs property here as well
            actions: [
              SignedOutAction((context) {
                const Text('you are logged out');
              }),
            ],
          );
        },
      },
    );

Flutter doctor

Run flutter doctor and paste the output below:

[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-arm, locale en-IL) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.69.0) [✓] Connected device (4 available) [✓] HTTP Host Availability

• No issues found!


Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

dependencies:
- cupertino_icons 1.0.5
- firebase_auth 3.4.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.19.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutterfire_ui 0.4.2+2 [cloud_firestore collection crypto desktop_webview_auth email_validator firebase_auth firebase_core firebase_database firebase_dynamic_links flutter flutter_facebook_auth flutter_localizations flutter_svg google_sign_in sign_in_with_apple twitter_login]
- google_sign_in 5.4.0 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]

nebarkay avatar Jul 10 '22 09:07 nebarkay

@nebarkay From the code sample you shared, I see that you are not passing client_id to the provider and hence it might be crashing and could be throwing below crash log:

Application Specific Information:
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
CoreSimulator 783.5 - Device: iPhone 13 (3BD8F2FF-FDB5-4074-8C91-54F99C79156D) - Runtime: iOS 15.2 (19C51) - DeviceType: iPhone 13
terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|'
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
abort() called

As you can see, it points to:

terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|'

Do you get same crash log or different from this ?

Can you also try to pass the client_id and then try and see if you still get error or not ?

darshankawar avatar Jul 11 '22 10:07 darshankawar

Hey @nebarkay. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jul 20 '22 01:07 google-oss-bot

IOS, MS It doesn't work on the web either. The settings are all ok, I used the default ui. Email login works fine.

  firebase_core: ^1.20.0
  firebase_auth: ^3.5.0
  firebase_storage: ^10.3.3
  cloud_firestore: ^3.4.0
  cloud_functions: ^3.3.3
  google_sign_in: ^5.4.0
  flutterfire_ui: ^0.4.3

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale ko-KR) • Flutter version 3.0.5 at /Users/patrick386/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (9 days ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/patrick386/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1

https://user-images.githubusercontent.com/49754877/180434535-49e577aa-3abb-42db-8788-d589e28c0878.mov


    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.134

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Patrick386 avatar Jul 22 '22 11:07 Patrick386

Fine for Android. In iOS, I'm able to click the Sign in with Google button and the modal appears, but there's nothing in the modal. Not sure how that happens. Then when I cancel the modal the app crashes.

I was following this video

Here is the blank modal:

enter image description here

Here is the PlatformException:

enter image description here

Here is what I've done:

Ran flutterfire configure

  • Selected android, ios, web
  • applied Firebase configuration for Android, yes
  • Created a new Firebase project

In Firebase Console

  • Downloaded GoogleService-Info.plist
  • Didn't do Steps 3 or 4 in SDK Instructions since the one time I got it to work I didn't do those steps, and every video I've watched skips them (though I did try two times doing them, but to no avail)

In Xcode

  • chose add files to "Runner", and added GoogleService-Info.plist that was downloaded from Firebase

In ios/Runner/Info.plist

Following the google_sign_in package, I added this code right before the last tag, and change the ID as stated, which I got from the GoogleService-Info.plist

<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<!-- TODO Replace this value: -->
			<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
			<string>com.googleusercontent.apps.85...</string>
		</array>
	</dict>
</array>
<!-- End of the Google Sign-in Section -->

In main() added:

then changed the clientId, which I got from the GoogleService-Info.plist

WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());

  FlutterFireUIAuth.configureProviders([
    // iOS
    const GoogleProviderConfiguration(
      clientId:
          '85... .apps.googleusercontent.com',
    ),
  ]);
  

(Flutter 3.0.5 * channel stable) Also tried:

  1. Uninstalled the app and reinstalled
  2. Installed Xcode 13.3.1, instead of 13.4
  3. Deleted Pods folder, Podfile.lock, and .symlinks folder, then tried again

MORE INFO: The first time running the app after changing Xcode version (2) and deleting pods info (3), I got a few different, random screens.

This one didn't crash when I hit cancel, like every other time, but it did stay on this screen for a few minutes so I canceled it: Screen Shot 2022-07-22 at 10 41 08 AM

After re-pressing Sign In button a few times I got this screen (never saw this before): Screen Shot 2022-07-22 at 10 58 09 AM

Then I restarted the app and it continued to give the blank screen from here on out.

dhust avatar Jul 22 '22 16:07 dhust

Hey @nebarkay. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Aug 02 '22 01:08 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@nebarkay if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Aug 11 '22 01:08 google-oss-bot