本文介绍了不推荐使用"com.google.android.gms.common.api.GoogleApiClient"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在我的应用程序中使用Google登录方法,并且今天我已将依存关系更新为:

I'm using in my app Google sign-in method and I have updated today my dependencies to:

implementation "com.google.firebase:firebase-core:17.1.0"
implementation "com.google.firebase:firebase-auth:19.0.0"

我凝视着关于过时的类的警告.

And I stared to get warnings about deprecated classes.

还有

这是我的代码:

static GoogleApiClient provideGoogleApiClient(Application app) { //deprecated
    return new GoogleApiClient.Builder(app) //deprecated
            .addApi(Auth.GOOGLE_SIGN_IN_API).build();
}

我的应用程序仍在运行,但是如何在不需要降级版本的情况下摆脱此警告?

My app is still working but how can I get rid of this warnings without the need to downgrade the versions?

推荐答案

是的,已弃用GoogleApiClient.

Yeah GoogleApiClient has been deprecated.

根据文档:

特别是对于身份验证api,您现在需要使用GoogleSignInClient.

Particularly for the authentication api, you now need to use GoogleSignInClient.

    // Configure sign-in to request the user's ID, email address, and basic
    // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();

    // Build a GoogleSignInClient with the options specified by gso.
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

您可以参考以下文档以了解更多详细信息:

You may refer following documentations for more details:

  • Integrating Google Sign-In into Your Android App
  • Moving Past GoogleApiClient

这篇关于不推荐使用"com.google.android.gms.common.api.GoogleApiClient"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 16:36