当我从默认登录选项调用 GoogleSignInOptions 时,会显示一个登录 UI
GoogleSignInOptions ClientInfo = GoogleSignInOptions.Builder.(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
GoogleSignInClient mGoogleSignInClient = GoogleSignInClient.getClient(this, ClientInfo);
Intent SignInintent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(SignInintent,3000);
但是,如果我使用默认游戏登录来调用 GoogleSignInOptions。我根本没有显示任何 UI,事实上,我会看到一盏昏暗的灯光,好像它想要显示,但随后又消失了。
GoogleSignInOptions ClientInfo = GoogleSignInOptions.Builder. GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).requestEmail().build();
GoogleSignInClient mGoogleSignInClient = GoogleSignInClient.getClient(this, ClientInfo);
Intent SignInintent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(SignInintent,3000);
最佳答案
我也遇到了同样的问题。检查 SHA-1、packageName 和 https://developers.google.com/games/services/android/troubleshooting 中列出的其他可能的问题没有产生任何有效的结果。通过将直接写入字符串资源中的元数据的 app_id 解决了我的问题。真的,我不知道为什么,但它有效。
之前:
AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="XXXXXXXXXXXX" />
之后:
AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
res/values/games_ids:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- app_id -->
<string name="app_id" translatable="false">XXXXXXXXXXXX</string>
</resources>
关于java - GoogleSignIn 有效,但 Google_DEFAULT_GAMES 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50776148/