показать проверку во время выполнения при входе в Google - PullRequest
0 голосов
/ 28 июня 2019

показать ошибку подтверждения при входе в Google в Android Firebase. Я добавляю все зависимости для знака Google, но по-прежнему показываю ошибку проверки во время выполнения. Я подключаю это приложение с помощью firebase, чтобы войти с помощью входа Google.

основная деятельность

public class MainActivity extends AppCompatActivity {

SignInButton signInButton;
private GoogleApiClient googleApiClient;
private FirebaseAuth mAuth;
TextView textView;
private static final int GOOGLE_SIGN = 1;
GoogleSignInClient mGoogleSignInClent;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mAuth = FirebaseAuth.getInstance();

   /* googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this,this)
            .addApi(mAuth.GOOGLE_SIGN_IN_API,gso)
            .build();*/

    GoogleSignInOptions gso = new GoogleSignInOptions
            .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();

    mGoogleSignInClent = GoogleSignIn.getClient(this,gso);




    SignInButton signInButton = findViewById(R.id.sign_in_button);
    signInButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            signIn();
        }
    });

    if(mAuth.getCurrentUser()!=null)
    {
        FirebaseUser user = mAuth.getCurrentUser();
        update(user);
    }

}



private void signIn()
{
    Intent signInIntent = mGoogleSignInClent.getSignInIntent();
    startActivityForResult(signInIntent, GOOGLE_SIGN);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode == GOOGLE_SIGN)
    {
        Task<GoogleSignInAccount> task =GoogleSignIn.getSignedInAccountFromIntent(data);

        try
        {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            if(account != null)
                firebaseAuthWithGoogle(account);

        }
        catch(Exception e)
        {
            Log.e("error",e.toString());
        }
    }
}

private void firebaseAuthWithGoogle(GoogleSignInAccount account)
{
    AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(),null);
    mAuth.signInWithCredential(credential).addOnCompleteListener(this, task -> {
        if(task.isSuccessful())
        {
            FirebaseUser user = mAuth.getCurrentUser();
            update(user);
        }
        else
        {
            Toast.makeText(this,"error",Toast.LENGTH_SHORT).show();
            update(null);
        }
    });
}

private void update(FirebaseUser user)
{
    if(user != null)
    {
        String name = user.getDisplayName();
        String email = user.getEmail();
        Toast.makeText(this,""+name+" "+email,Toast.LENGTH_SHORT).show();
    }
}
}

Gradle

implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.google.firebase:firebase-firestore:17.1.2'
implementation 'com.google.firebase:firebase-core:16.0.5'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

mainactivity.xml

<LinearLayout 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=".UI.MainActivity"
android:orientation="horizontal">

<com.google.android.gms.common.SignInButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/sign_in_button"
    android:layout_marginLeft="110dp"
    android:layout_gravity="center"
    app:buttonSize="wide"></com.google.android.gms.common.SignInButton>


</LinearLayout>

эта ошибка отображается во время выполнения, дайте мне знать, в чем проблема

E / AndroidRuntime: ИСКЛЮЧИТЕЛЬНОЕ ИСКЛЮЧЕНИЕ: main

Процесс: com.example.coludfirestore, PID: 31004

java.lang.VerifyError: верификатор отклонил класс com.google.android.gms.auth.api.signin.GoogleSignInClient: int com.google.android.gms.auth.api.signin.GoogleSignInClient.zzach () не удалось проверьте: int com.google.android.gms.auth.api.signin.GoogleSignInClient.zzach (): [0xF] ссылка "этот" аргумент: com.google.android.gms.common.GoogleApiAvailability ", а не экземпляр" Precise Ссылка: com.google.android.gms.common.zzf '(объявление com.google.android.gms.auth.api.signin.GoogleSignInClient' отображается в /data/app/com.example.coludfirestore-mlIQUAwJCuv8NfVJG2UK8g== /split_lib_dependencies_apk.apk) на com.google.android.gms.auth.api.signin.GoogleSignIn.getClient (неизвестный источник: 0) в com.example.coludfirestore.UI.MainActivity.onCreate (MainActivity.java:56)

...