我試圖按照指南在我的應用程序上實施 Google 登錄。但是,每次嘗試登錄時,我都會收到錯誤 10,我知道這意味著開發人員錯誤,但我無法弄清楚自己做錯了什么。我實現了所有代碼,確保我有正確的包并更新了 Android Studio。我嘗試了來自 SHA1 哈希的不同客戶端 ID,這些哈希來自為我的應用程序生成的多個簽名包和 apk。我嘗試了 Google 為您提供的用于登錄的預生成的。有任何想法嗎?谷歌登錄的意圖GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)? ? ? ? ? ? ? ? .requestEmail()? ? ? ? ? ? ? ? .requestIdToken(getString(R.string.server_client_id))? ? ? ? ? ? ? ? .build();? ? ? ? googleSignInClient = GoogleSignIn.getClient(getActivity(),gso);? ? ? ? Intent signInIntent = googleSignInClient.getSignInIntent();? ? ? ? startActivityForResult(signInIntent, 21);OnActivityResult 函數? ? @Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) {? ? callbackManager.onActivityResult(requestCode, resultCode, data);? ? super.onActivityResult(requestCode, resultCode, data);? ? if(requestCode == 21) {? ? ? ? Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);?? ? ?handleSignInResult(task);? ? }? ? else if (resultCode == RESULT_CANCELED)? ? {? ? ? ? Log.d("frag", "intent fired and something went wrong");? ? }}handleSignInResult 函數? ? private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {? ? try {? ? ? ? GoogleSignInAccount account = completedTask.getResult(ApiException.class);? ? ? ? // Signed in successfully, show authenticated UI.? ? ? ? Log.d("frag", "Email of account is " + account.getEmail());? ? } catch (ApiException e) {? ? ? ? // The ApiException status code indicates the detailed failure reason.? ? ? ? // Please refer to the GoogleSignInStatusCodes class reference for more information.? ? ? ? Log.w("ytsignin", "signInResult:failed code=" + e.getStatusCode());? ? }}
1 回答

暮色呼如
TA貢獻1853條經驗 獲得超9個贊
在開發人員控制臺中檢查 SHA-1 代碼和包名稱。大多數情況下,它是導致錯誤 10 的原因,即“DEVELOPER_ERROR”。將控制臺中的 SHA-1 與運行 signingReport 后從 Android Studio 獲得的 SHA-1 進行比較。
添加回答
舉報
0/150
提交
取消