java - GoogleSignIn 有效,但 Google_DEFAULT_GAMES 无效

标签 java android google-play-games android-googleapiclient

当我从默认登录选项调用 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/

相关文章:

Android Retrofit 2.0 刷新 token

android - 保存的游戏 + 实时多人 Android

android - Google Play 游戏服务 : socket-based messaging

java - 如何正确从mysql数据库中选择数据?结果集错误

java - android - XMLPullParser 错误

java - 如何防止列表字段自动刷新后显示重复数据

java - google play services 无法实例化 Activity ComponentInfo java.lang.ClassNotFoundException

java - 配置从 Tomcat 中的类文件夹而不是 lib 文件夹中获取类?

android - ImageView 裁剪为多边形

android - 如何从我的 DatePicker fragment 传输格式化的日期字符串?