Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using Firebase, GoogleSignIn is marked as internal and should not be accessed from apps

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>
like image 800
Dori Avatar asked Mar 24 '18 11:03

Dori


1 Answers

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.
like image 137
N1hk Avatar answered Oct 23 '22 03:10

N1hk