简体   繁体   English

使用Google for Android登录无法在发行版APK中运行

[英]Sign-in with google for android not working in release apk

I have added the Google Sign in in my application and made it work by following all the steps in the official documentation. 我已经在应用程序中添加了Google登录,并按照官方文档中的所有步骤进行了操作。 Everything worked fine, until I generated a signed apk for publishing. 一切正常,直到我生成了一个已签名的APK以供发布。 The app could not sign in , the 该应用无法登录,

Log.d(TAG, "handleSignInResult:" + result.isSuccess()); Log.d(TAG,“ handleSignInResult:” + result.isSuccess());

in SignInActivity.java's handleSignInResult() gives the value as false . 在SignInActivity.java的handleSignInResult() ,其值为false

I have registered the app on the developer console and provided the SHA1 key for they debug key as well as the release key. 我已经在开发者控制台上注册了该应用,并为其提供了SHA1密钥,调试密钥和发行密钥。 I am unable to solve this and couldn't find anything related in the documentation either. 我无法解决此问题,也无法在文档中找到任何相关内容。

When you upload an apk to the play store then play store creates a new SHA1 key called "App signing certificate". 当您将APK上传到Play商店时,Play商店会创建一个新的SHA1密钥,称为“应用程序签名证书”。 You get that SHA1 and save in your console or firebase account (as you need). 您获得该SHA1并保存在您的控制台或firebase帐户中(根据需要)。

New SHA1 will be found at Released Management->App Sigining on your play console. 新的SHA1将在您的游戏机上的Released Management-> App Sigining中找到。

or 要么

when you build signed apk with your filename.jks it has different SHA than your debug apk, put these SHA which is generated by signed apk in Firebase nd update it and again download json from firebase and override existing json from your android studio. 当您使用filename.jks构建签名的apk时,它与调试apk的SHA有所不同,将这些由签名apk生成的SHA放在Firebase中,并对其进行更新,然后再次从firebase下载json并从android studio中覆盖现有的json。

For complete release process you can go here 有关完整的发布过程,请转到此处

Finally solved it. 终于解决了。 I added the SHA1 key for my release key (the .jks file) in the Google Developers Console under the project registered. 我在已注册项目下的Google Developers Console中为发布密钥( .jks文件)添加了SHA1密钥。 In Android Studio, at the left side, there is an option for Build variants under the project view. 在Android Studio中,左侧在项目视图下提供了Build变体选项。 There, I changed each module to release mode (it is in debug mode by default). 在那里,我将每个模块更改为release模式(默认情况下处于debug模式)。 Then created the Signed APK by usual method, and run the app. 然后通过常规方法创建Signed APK,然后运行该应用程序。 The Google Signin worked perfectly. Google登录完美运行。

更改构建变体

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM