I'm trying to retrieve a list of the signed-in user's contact emails in my Android app. Starting with the tutorial here, the following line:
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
results in the Android Studio error "GoogleSignIn is marked as internal and should not be accessed from apps".
The project compiles, but when I try to sign in, logcat
outputs:
W/GooglePlayServicesUtil: Google Play services out of date. Requires 12210000 but found 11947470
My app/gradle.build
contains:
dependencies {
...
implementation 'com.google.android.gms:play-services-auth:12.0.0'
implementation 'com.google.firebase:firebase-core:12.0.0'
implementation 'com.google.firebase:firebase-firestore:12.0.0'
}
apply plugin: 'com.google.gms.google-services'
and when I comment Firebase out:
dependencies {
...
implementation 'com.google.android.gms:play-services-auth:12.0.0'
//implementation 'com.google.firebase:firebase-core:12.0.0'
//implementation 'com.google.firebase:firebase-firestore:12.0.0'
}
//apply plugin: 'com.google.gms.google-services'
I don't get the error and successfully sign in.
I want to integrate Firestorm into my app, do I need to redesign the sign-in process? If so, how?
To reproduce, here's my MainActivity
. With Firebase compiled, the Log.w
call outputs signInResult:failed code=12500
:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
static final int RC_SIGN_IN = 1000;
GoogleSignInClient mGoogleSignInClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
findViewById(R.id.google_sign_in_button).setOnClickListener(this);
}
@Override
public void onClick(View v) {
startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignInResult(task);
}
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
} catch (ApiException e) {
Log.w("signInResult:failed code=" + e.getStatusCode());
}
}
}
and my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.XXX.MainActivity">
<com.google.android.gms.common.SignInButton
android:id="@+id/google_sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
https://developers.google.com/android/guides/releases
Known Issues with version 12.0.0
...
- An annotation causes spurious lint errors claiming GoogleSignIn and CredentialsClient are internal-only. These can safely be ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With