Java 如何从Android应用程序登录Google Play游戏(错误8)

Java 如何从Android应用程序登录Google Play游戏(错误8),java,android,google-play-games,Java,Android,Google Play Games,我试图将保存游戏添加到Google Play games云服务到现有的android应用程序中,但出现错误8 我正在使用和 这就是我迄今为止所尝试的: 控制台和安全设置 在游戏服务中创建游戏。已保存的游戏打开,所有其他功能关闭 使用“链接的应用程序”并使用调试SHA1指纹链接 在GoogleAPI控制台中进行了上述验证,所有这些都在控制台中使用keytool签出并匹配SHA1十六进制字符串 keytool -list -keystore "C:\Users\dejan\.android\debu

我试图将保存游戏添加到Google Play games云服务到现有的android应用程序中,但出现错误8

我正在使用和

这就是我迄今为止所尝试的:

控制台和安全设置 在游戏服务中创建游戏。已保存的游戏打开,所有其他功能关闭

使用“链接的应用程序”并使用调试SHA1指纹链接

在GoogleAPI控制台中进行了上述验证,所有这些都在控制台中使用keytool签出并匹配SHA1十六进制字符串

keytool -list -keystore "C:\Users\dejan\.android\debug.keystore" -storepass android
添加了我自己作为测试人员,并启用了所有环境的测试

SDK管理器 在Android Studio中,使用SDK工具添加“Google Play服务”

安卓清单 在android清单中添加了以下内容:

   <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>
在已添加的OnCreated方法中:

   //initialize google play games
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
                // Since we are using SavedGames, we need to add the SCOPE_APPFOLDER to access Google Drive.
                .requestScopes(Drive.SCOPE_APPFOLDER)
                .build();
        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
对于按钮,请单击“添加”:

startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN);
最后,添加了ActivityResult

  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (requestCode == RC_SIGN_IN) {

        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(intent);

        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            onConnected(account);
        } catch (ApiException apiException) {
            String message = String.format("%s (%s)", getString(R.string.signin_other_error), apiException.getStatusCode());
            mGoogleSignInError = true;
            Snackbar snackbar = Snackbar.make(findViewById(R.id.mainContainerMenu), message, Snackbar.LENGTH_LONG);
            snackbar.show();

            onDisconnected();


        }
    }

    super.onActivityResult(requestCode, resultCode, intent);

}
@覆盖
ActivityResult上受保护的void(int-requestCode、int-resultCode、Intent-Intent){
if(requestCode==RC\u登录){
Task Task=GoogleSignIn.GetSignedAccountFromIntent(intent);
试一试{
GoogleSignInAccount account=task.getResult(ApiException.class);
未连接(帐户);
}捕获(ApiException ApiException){
String message=String.format(“%s(%s)”,getString(R.String.signin_other_error),apiException.getStatusCode();
mgooglesignError=true;
Snackbar Snackbar=Snackbar.make(findviewbyd(R.id.mainContainerMenu),message,Snackbar.LENGTH\u LONG);
snackbar.show();
onDisconnected();
}
}
super.onActivityResult(请求代码、结果代码、意图);
}
测试 我试着将这个应用程序从Android Studio运行到我的物理设备上,在那里我以测试授权用户的身份登录

此外,还尝试通过Android Studio制作一个签名的apk,并使用adb命令将其部署到设备上。构建apk时,使用调试密钥存储和密钥

在这两种情况下,我都得到了错误#8。Google Play启动屏幕没有显示,屏幕只是暗了一秒钟,然后我得到一个错误

Logcat 2019-02-26 18:01:00.9464892-7664/?E/截击:[131]基本网络。性能请求:的意外响应代码404

2019-02-26 16:15:29.365 1517-18694/?I/ActivityManager:pkg=com.google.android.gms.auth.google\u SIGN\u中的u0{act=com.google.android.gms cmp=com.google.android.gms/.auth.api.signin.ui.SignInActivity(has extras)}从屏幕0上的uid 10351启动

2019-02-26 16:15:29.3781517-31079/?E/ActivityManager:从系统4525发送不受保护的广播com.motorola.motocare.INTENT_触发器:com.motorola.process.system/1000 pkg com.motorola.motgeofeensvc java.lang.Throwable 位于com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:18226) 位于com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:18826) 位于android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:512) 位于com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2906) 位于android.os.Binder.execTransact(Binder.java:565)


清单中是否缺少某些权限?感谢您的帮助。

尝试添加各种权限,但documnetation没有;我不认为这是必要的,但思考可能会有所帮助。。。我也有同样的问题。还没有找到任何解决方案…没有,转到其他方面,将重新访问soonTried添加各种权限,documnetation没有;我不认为这是必要的,但思考可能会有所帮助。。。我也有同样的问题。还没有找到任何解决方案…没有,转到其他方面,很快将重新访问
  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (requestCode == RC_SIGN_IN) {

        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(intent);

        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            onConnected(account);
        } catch (ApiException apiException) {
            String message = String.format("%s (%s)", getString(R.string.signin_other_error), apiException.getStatusCode());
            mGoogleSignInError = true;
            Snackbar snackbar = Snackbar.make(findViewById(R.id.mainContainerMenu), message, Snackbar.LENGTH_LONG);
            snackbar.show();

            onDisconnected();


        }
    }

    super.onActivityResult(requestCode, resultCode, intent);

}