[英]Android Google Sign In: App Release Build Always Got “Error: 12500”, While Debug Build Isn't
So, as the title said, I always failed at sign in with error code "12500" every time I'm using release apk, but always successfully signed in when on debug apk. 因此,正如标题所述,每次使用发行版apk时,我始终以错误代码“ 12500”登录失败,但是在调试apk上时,始终成功登录。 Already updated Google Play Services to the latest version, also re-downloaded the google-services.json.
Google Play服务已更新至最新版本,还重新下载了google-services.json。 Still failed sign in by error code "12500" on release apk.
在发行版APK上仍然无法通过错误代码“ 12500”登录。
My Activity: 我的活动:
public class ActivityLogin extends AppCompatActivity {
@BindView(R.id.iv_google)ImageView ivGPlus;
private GoogleSignInClient mGoogleSignInClient;
private final int RC_SIGN_IN = 123;
private Context context;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
prepareGoogle();
initUI();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
} catch (ApiException e) {
e.printStackTrace();
}
}
}
private void initUI(){
ivGPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signInGoogle();
}
});
}
//login google
private void prepareGoogle(){
mAuth = FirebaseAuth.getInstance();
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getResources().getString(R.string.default_web_client_id))
.requestServerAuthCode(getResources().getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
}
private void signInGoogle() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
}
I also already disabled the proguard: 我也已经禁用了proguard:
android {
compileSdkVersion 27
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 27
versionCode 17
versionName "1.1.9.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode = true
}
}
Since it is working in your debug build, this error is mostly due to a SHA key or package name issue. 由于它在您的调试版本中起作用,因此此错误主要是由于SHA密钥或程序包名称问题引起的。 You said you have the latest
google-services.json
, so I am assuming you have included the SHA fingerprint for the release keystore in your Firebase project? 您说您拥有最新的
google-services.json
,所以我假设您在Firebase项目中包括了发行密钥库的SHA指纹?
If not, you will have to get the fingerprint as explained in this answer and then add it to your Firebase project, and update the google-services.json
again. 如果没有,您将必须按照此答案中的说明获取指纹,然后将其添加到Firebase项目中,然后再次更新
google-services.json
。
If that has already been done, and you are facing the issue on an app released to the Google Play store, you should check if you have enrolled in Google App Signing , since it involves two distinct upload and signing keys. 如果这样做已经完成,并且您在发布到Google Play商店的应用中遇到问题,则应检查是否已注册Google App签名 ,因为它涉及两个不同的上载和签名密钥。
You must include the signing key for it to work on user devices. 您必须包括签名密钥,才能在用户设备上使用它。 If you are sideloading the app for testing, after creating a release apk with the upload key, then you will have to include that as well.
如果您要侧面加载该应用程序进行测试,请在使用上传密钥创建发布apk之后,还必须包括该版本。
I can provide more details depending on your situation. 我可以根据您的情况提供更多详细信息。 Editing your question and including the relevant portion of
logcat
when the error is raised would make it easier to provide accurate advice. 编辑您的问题,并在出现错误时包括
logcat
的相关部分,可以更轻松地提供准确的建议。
Accepted answer didn't help in my case. 接受的答案对我来说没有帮助。 I've checked SHA keys everywhere and they matched.
我到处都检查过SHA键,并且它们匹配。 Local debug worked, local release worked, but after publishing app to Play store all versions were giving 12500 error with Google Sign In (alfa, beta, production).
可以进行本地调试,可以进行本地发行,但是在将应用发布到Play商店后,所有版本都因Google登录(Alfa,Beta版,正式版)出现12500错误。
So I asked Google a slightly different question and stumbled upon a thread on github about react native and google sign in. Answer by HadrienPierart helped me find and fix the problem. 所以我问Google一个稍微不同的问题,偶然发现github上有一个关于本机和Google登录反应的线程。HadrienPierart的回答帮助我找到了并解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.