![](/img/trans.png)
[英]MissingPluginException(No implementation found for method init on channel plugins.flutter.io/google_sign_in) after publishing to Google Play Store
[英]MissingPluginException(No implementation found for method init on channel plugins.flutter.io/google_sign_in)
使用 Flutter 的 google sign_in
但是當我使用此語句登錄用戶時看到以下消息
_googleSignIn.signIn();
E/flutter(6491):MissingPluginException(未在通道插件上找到方法 init 的實現。flutter.io/google_sign_in)
我驗證了以下步驟:
GoogleSignInPlugin.registerWith(registry.registrarFor("io.flutter.plugins.googlesignin.GoogleSignInPlugin")); // is present
GeneratedPluginRegistrant.registerWith(this); // in MainActivity.Java
用戶是否經常報告此錯誤。 不確定如何進行。 我正在做大多數文檔所說的,但它不起作用。
我看到的其他奇怪行為是,我第一次運行 flutter 時,它卡在等待 googleSignIn.SignIn() 上。
只有在我進行熱重載(通過鍵入“r”)之后,我才會看到上面的錯誤消息:
E/flutter (12326): MissingPluginException (No implementation found for method init on channel plugins.flutter.io/google_sign_in)
問題:是否有其他方法可以對 Flutter 應用程序進行基本身份驗證。 我只需要某種基本身份驗證,以便我的服務器可以知道它正在為哪個用戶提供數據。
運行flutter clean
並重新啟動IDE以及完全重新構建應用程序。 這將修復它。
當我遇到這個問題時,我一直在頭疼。 終於我意識到我做錯了什么。 我必須執行以下步驟
1>切換到master分支flutter channel master
2> flutter upgrade
3> flutter clean
4>最重要的部分,檢查你是否有facebook插件。 如果是,請完全設置(未測試)或將其刪除(有效),因為它與 google 插件混淆
最后我在顫振中發現了問題,因為 google 和 facebook login pub 之間存在沖突
在 pubspec.yaml 文件中
google_sign_in: ^4.5.3
flutter_facebook_login: ^3.0.0 -> 刪除這個
並評論 Facebook 登錄的所有代碼
事實證明,您不必刪除flutter_facebook_login
即可使google_signin
工作。 當flutter_facebook_login
在注冊期間拋出並阻止google_sign_in
注冊時, flutter_facebook_login
發生這種情況, flutter_facebook_login
flutter 的官方 repo 貢獻者在此處所說的那樣。
該線程的評論之一中提供的解決方案是在AndroidManifest.xml
注冊 Facebook 插件,我也忘記了。 在清單中注冊 Facebook 解決了這個問題。
要添加到清單中的代碼是:
<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>
不要忘記在strings.xml
添加所需的strings.xml
作為
<string name="app_name">Your App Name</string> <!-- app name on fb -->
<string name="facebook_app_id">Your FB ID</string> <!-- fb app id -->
<string name="fb_login_protocol_scheme">Your FB protocol scheme</string> <!-- fb+ fb app id -->
對我來說是再次安裝豆莢
在顫振項目目錄中打開終端並寫入
cd ios
pod install
它最近發生在 Flutter 存儲庫的 beta 頻道上。 考慮從穩定渠道簽出。
我一次嘗試了很多東西,所以我不太確定,但我想這解決了問題。
flutter_facebook_login: ^3.0.0 -> remove this one
記住在flutter項目中安裝插件后,熱重載或者重啟都會拋出這個錯誤(缺少插件異常),需要重新運行app! 熱重載僅支持純 dart 代碼,插件包含本地代碼,如 java 或 swift,這些代碼必須可用於 dart 代碼,因此重新編譯是將本地代碼推送到設備上運行的應用程序的唯一選項。
您可以停止應用程序並嘗試使用此命令
1 flutter doctor
如果有問題請修復
2 flutter clean
3 flutter run -v
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.