我已经创建了一个应用,今天已上传到Alpha测试轨道。但是我面临一些问题。我已经实现了Firebase身份验证(Google登录)。将应用上传到Play商店后,Google登录失败(在Play商店上载应用之前,身份验证工作正常)。
以下是代码(Google登录)
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signIn();
}
});
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignIn(task);
}
}
private void handleSignIn(Task<GoogleSignInAccount> completedTask) {
try {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
Toast.makeText(this, "success", Toast.LENGTH_SHORT).show();
firebaseAuthWithGoogle(account);
} catch (ApiException e) {
// Google Sign In failed, update UI appropriately
Log.e("TAG_failure", "Google sign in failed");
Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
loadingDialog.show();
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
loadingDialog.dismiss();
Log.d("TAG_S", "signInWithCredential:success");
FirebaseUser user = mAuth.getCurrentUser();
//firebaseDataHandler();
queryData();
authLayout.setVisibility(View.GONE);
} else {
// If sign in fails, display a message to the user.
Log.e("TAG_F", "signInWithCredential:failure", task.getException());
//updateUI(null);
loadingDialog.dismiss();
}
}
});
}
这是 build.gradle
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
上传应用程序到游戏机后,Google in app购买也无法正常工作
在 proguard-rules.pro 中,我添加了这一行
-keep class com.android.vending.billing.**
我还添加了“结算”权限,但我不知道为什么这不起作用
<uses-permission android:name="com.android.vending.BILLING" />
有我不知道的令人困惑的问题吗?
在此先感谢您的帮助。
答案 0 :(得分:1)
我添加了这些行,问题就解决了
proguard-rules.pro
{{1}}