'PlusClass'已经过时了

时间:2017-03-30 17:20:01

标签: xamarin.android google-plus google-api-client

初始化GoogleApiClient时,我收到此警告:

  

'PlusClass'已经过时了:'这个类在这个android中已经过时了   平台“

它的替代方案是什么?

代码:

mGoogleApiClient = new GoogleApiClient.Builder(this)
   .AddConnectionCallbacks(this)
   .AddOnConnectionFailedListener(this)
   .AddApi(PlusClass.API)
   .AddScope(new Scope(Scopes.Profile))
   .Build();

版本:

  <package id="Xamarin.GooglePlayServices.Base" version="42.1001.0" targetFramework="monoandroid71" />
  <package id="Xamarin.GooglePlayServices.Basement" version="42.1001.0" targetFramework="monoandroid71" />
  <package id="Xamarin.GooglePlayServices.Plus" version="42.1001.0" targetFramework="monoandroid71" />
  <package id="Xamarin.GooglePlayServices.Tasks" version="42.1001.0" targetFramework="monoandroid71" />

1 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,经过大量的挖掘和逆向工程java示例后,我得到了下面的代码。

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
        .RequestProfile()
        .Build();

    _GoogleApiClient = new GoogleApiClient.Builder(this)
        .AddConnectionCallbacks(this)
        .AddOnConnectionFailedListener(this)
        .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .Build();
}

<package id="Xamarin.GooglePlayServices.Auth" version="42.1001.0" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Auth.Base" version="42.1001.0" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Base" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Basement" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Location" version="42.1001.0" targetFramework="monoandroid70" />
<package id="Xamarin.GooglePlayServices.Plus" version="42.1001.0" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Tasks" version="42.1001.0" targetFramework="monoandroid70" />