简体   繁体   English

Play 游戏登录在 Play 商店中发布后不起作用,但当我在我的 android 设备上测试时它在 android 工作室工作

[英]Play Games Sign in does not work after publishing it in play store but it was working when i tested on my android device from android studio

Play games sign in is not working in my app after i published it.在我发布应用后,玩游戏登录在我的应用中不起作用。 I am unable to understant what is the problem These are the functions created for signingin and for achievements and leaderboard.I think problem is related to OAuth Server but i dont know how to do it.Can Somone Explain it.我无法理解问题是什么这些是为登录、成就和排行榜创建的功能。我认为问题与 OAuth 服务器有关,但我不知道该怎么做。Somone 可以解释一下吗?

private fun startSignInIntent() {
    val signInClient = GoogleSignIn.getClient(this,
            GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    val intent = signInClient.signInIntent
    startActivityForResult(intent, RC_SIGN_IN)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == RC_SIGN_IN) {
        val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
        if (result!!.isSuccess) {
            mServerAuthCode = result.signInAccount!!.serverAuthCode
            // The signed in account is stored in the result.
            val signedInAccount = result.signInAccount
        } else {
            var message = result.status.statusMessage
            if (message == null || message.isEmpty()) {
                message = getString(R.string.signin_other_error)
            }
            AlertDialog.Builder(this).setMessage(message)
                    .setNeutralButton(android.R.string.ok, null).show()
        }
    }
}
private fun showAchievements() {
    Games.getAchievementsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
        .achievementsIntent
        .addOnSuccessListener { intent -> startActivityForResult(intent, RC_ACHIEVEMENT_UI) }
}
private val RC_LEADERBOARD_UI = 9004
private fun showLeaderboard() {
    Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
        .getLeaderboardIntent(getString(R.string.leaderboard_marathon))
        .addOnSuccessListener { intent -> startActivityForResult(intent, RC_LEADERBOARD_UI) }
}
private fun showLeaderboard2() {
    Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
        .getLeaderboardIntent(getString(R.string.leaderboard_timer_mode))
        .addOnSuccessListener { intent -> startActivityForResult(intent, RC_LEADERBOARD_UI) }
}
private fun signOut() {
    val signInClient = GoogleSignIn.getClient(this,
            GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    signInClient.signOut().addOnCompleteListener(this
    ) {
        // at this point, the user is signed out.
    }
}
private fun signInSilently() {
    val signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
    val account = GoogleSignIn.getLastSignedInAccount(this)
    if (GoogleSignIn.hasPermissions(account, *signInOptions.scopeArray)) {
        // Already signed in.
        // The signed in account is stored in the 'account' variable.
        val signedInAccount = account
    } else {
        // Haven't been signed-in before. Try the silent sign-in first.
        val signInClient = GoogleSignIn.getClient(this, signInOptions)
        signInClient
                .silentSignIn()
                .addOnCompleteListener(
                        this
                ) { task ->
                    if (task.isSuccessful) {
                        val signedInAccount = task.result
            
                }
    }
}

After you publish the app on Play Store, Google signs it and the Google app signing key certificate needs to be registered in the project's Firebase console for it to work.在 Play Store 上发布应用程序后,谷歌对其进行签名,并且需要在项目的 Firebase 控制台中注册谷歌应用程序签名密钥证书才能运行。 After you publish the app, in the Play Console, under Release, click on Settings.发布应用后,在 Play 管理中心的发布下,点击设置。 Click on App Integrity.单击应用程序完整性。 Click on the App Signing tab.单击“应用程序签名”选项卡。 Copy the SHA-1 fingerprint to your clipboard.将 SHA-1 指纹复制到剪贴板。 Go to your Firebase Console and select your project. Go 到您的 Firebase 控制台和 select 您的项目。 To the right of Project Overview, click the gear icon and select Project Settings.在项目概览的右侧,单击齿轮图标和 select 项目设置。 Under Your Apps, click on your Android app and enter the SHA-1 fingerprint that you copied from the App Signing tab.在您的应用程序下,单击您的 Android 应用程序并输入您从应用程序签名选项卡复制的 SHA-1 指纹。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Android Studio Android 应用程序在设备上运行 Google plus 但从 Play 商店下载时不起作用 - Using Android Studio Android app Working Google plus on device but when downloaded from play store Not Work Play 游戏登录问题 - Android Studio JAVA - Sign in problem with Play Games - Android Studio JAVA 在 Play 商店中发布后,Google 登录无法正常工作 - Google sign in not working after publishing in play store 在 Play 商店中发布 Android 应用程序后,Firebase 云消息传递不起作用 - Firebase Cloud Messaging is not working after publishing Android app in play store 在Play商店发布我的应用程序后,我无法从任何手机下载它,因为它显示支持的设备“0” - After publishing my application on play store I cant download it from any phone as its showing supported device “ 0 ” 我在Play商店中的android应用说您的设备与该版本不兼容,但是当我尝试从apk安装它时 - My android app in play store says your device isn't compatible with the version, but when i try to install it from apk it is working Android 应用程序在 Play 商店发布后崩溃? - Android app crashes after publishing on Play Store? 在我的应用程序中配置multidex仍然可以在android studio上正常工作,但是尝试从Play商店下载时崩溃 - Configure multidex in my application still working fine on android studio but crash when try to download from play store Android Studio和Google Play游戏 - Android Studio and Google Play Games 在Google Play商店上发布应用程序后,如果该应用程序依赖于Google登录,该如何测试? - How do I test my app when it's dependent on Google sign in after publishing app on the Google Play Store?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM