Approaching to the final stage of the authentification, but something is going wrong in handleSignInResult
method. It returns Exception code 10 (Developer error) in logs. Google provides comprehensive description:
The application is misconfigured. This error is not recoverable and will be treated as fatal. The developer is an idiot...
What should I do to handle this (get an account) and finally retrive values from account?
Thank you in advance for your help!!!
MainActivity:
package ru.podgorny.carcall;
import ...
public class MainActivity extends AppCompatActivity {
SignInButton signInButton;
public static final int RC_SIGN_IN = 07;
public static final String TAG = "MainActivity";
TextView tw1;
TextView tw2;
GoogleSignInOptions gso;
GoogleSignInClient mGSC;
@Override
protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "Activity Works");
findViews();
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
//.requestProfile()
.build();
mGSC = GoogleSignIn.getClient(this, gso); //smth with mGSC variable....
View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
onClick2(v);
}
};
signInButton.setOnClickListener(onClickListener);
}
private void findViews() {
Log.d (TAG, "findViews started");
signInButton = findViewById(R.id.idButtonGoogle);
tw1 = findViewById(R.id.textView1);
tw1 = findViewById(R.id.textView2);
Log.d(TAG, "Views finded");
}
public void onClick2(View view) {
Log.d(TAG, "onClick started");
switch (view.getId()) {
case R.id.idButtonGoogle:
signIn();
break;
}
Log.d(TAG, "OnClick Started");
}
public void signIn() {
Intent signInIntent = mGSC.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
Log.d(TAG, "startActivityForResult works");
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "OnActivityResult started");
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
// The Task returned from this call is always completed, no need to attach
// a listener.
Log.d(TAG, "TASK started");
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignInResult(task);
Log.d(TAG, "OnActivityResult returned");
}
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);//ERROR -- Code 10
Log.d(TAG, "Account received");
updateUI(account);
Log.d(TAG, "updateUI Launched");
} catch (ApiException e) {
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
updateUI(null);
}
}
private void updateUI(GoogleSignInAccount account) {
if (account!=null) {
tw1.setText("OK");
tw2.setText("Name: " + account.getGivenName() + ", Family name: " + account.getFamilyName() + ", Email: " + account.getEmail() /*+ " image: " +
account.getPhotoUrl()*/);
}else {
tw1.setText("SMTH wrong");
}
}
}