簡體   English   中英

flutter google_sign_in 崩潰:__exceptionPreprocess + 294

[英]flutter google_sign_in crash : __exceptionPreprocess + 294

我在 flutter 應用程序中使用google_sign_in插件登錄。使用示例中的代碼登錄代碼只是:

GoogleSignIn _googleSignIn = new GoogleSignIn(
  scopes: <String>[
    'email',
    'https://www.googleapis.com/auth/spreadsheets',
    'https://www.googleapis.com/auth/drive.metadata',
  ],
);

Future<Null> _handleSignIn() async {
    print("_handleSignIn");
    try {
      await _googleSignIn.signIn();
    } catch (error) {
      print("We failed");
      print(error);
    }
  }

這適用於Android。 我按下登錄按鈕,然后有一個彈出窗口,我就可以登錄了。

但是,這個簡單的例子在 iOS 上崩潰了。 當應用程序調用_handleSignIn以上時, _googleSignIn.signIn()調用崩潰的應用程序(它消失),並顯示錯誤消息:

flutter: _handleSignIn
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010fe581e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010f4ed031 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010fecd975 +[NSException raise:format:] + 197
    3   Runner                              0x000000010ce61d8b -[GIDSignIn signInWithOptions:] + 242
    4   Runner                              0x000000010ce5e777 -[GIDSignIn signIn] + 64
    5   Runner                              0x000000010ce591b2 -[FLTGoogleSignInPlugin handleMethodCall:result:] + 2114
    6   Flutter                             0x000000010d1af716 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 118
    7   Flutter                             0x000000010d1c5370 _ZNK5shel<…>
Lost connection to device.

我沒有構建 iOS 應用程序的經驗,所以我可能做錯了什么。 我按照說明添加了來自 firebase.com 的GoogleService-Info.plist並按照說明更新了我的Info.plist

有任何想法嗎? 有什么方法可以獲得更好的錯誤消息,以便我找出可能出了什么問題?

剛剛有同樣的問題。 那是因為我添加了 Google 和 Facebook 登錄。

解決方案:

調整Info.plist。 搜索CFBundleURLTypes 你會看到你擁有它兩次。 那是錯的。 從 Facebook 中復制<string>fb??????????????</string>部分並將其粘貼到 Google 部分中的相同數組中。 然后從 Facebook 部分刪除CFBundleURLTypes

背景:

如果您只是按照 Google 登錄和 Facebook 登錄中的說明進行操作,那么您將為 Google 粘貼CFBundleURLTypes部分,為 Facebook 粘貼一個CFBundleURLTypes部分。 只有后一個會被撿起來。 所以谷歌不在那里。 因此,當嘗試使用 google sign in 登錄時,它會引發異常,因為它沒有正確設置。 因為 google url scheme 被 facebook 覆蓋了。

幫助我找出問題的相關問題:

我的情況是我更新了GoogleService-Info.plist但忘記根據Info.plist REVERSED_CLIENT_ID更新CFBundleURLTypes

不知道是什么問題。 我重新做了一遍,現在它起作用了。 也許這是一個剪切-粘貼錯誤。

我所做的唯一新事情是在“常規”選項卡中將“團隊”設置為我的“個人團隊”。 以前它是未設置的。 不知道這是否重要。

設置團隊

如果您成功地將GoogleService-Info.plist移動到正確的目錄並將CFBundleURLTypes添加到您的Info.plist ,但仍然遇到崩潰,那么原因可能在於 google_sign_in 包本身。

此軟件包在 iOS 設備上存在一個已知問題( Futter 問題

長話短說:一個名為 @buuth 的用戶發現,對屬性hostedDomainclientId的空檢查很簡單,因此您只需要顯式設置它們。

GoogleSignIn googleSignIn = GoogleSignIn( 
  scopes: ['email','profile'],
  hostedDomain: "", 
  clientId: "",);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM