C# 如何在Xamarin中获取GoogleAppClient实例?

C# 如何在Xamarin中获取GoogleAppClient实例?,c#,android,xamarin,xamarin.android,C#,Android,Xamarin,Xamarin.android,我想将我的xamarin android应用程序与google play services排行榜和成就进行集成。我不知道如何将下面的代码从转换为c 我试着转换如下的东西 GoogleApiClient api = new GoogleApiClient.Builder(this) .AddApi(Android.Gms.Games.API) .Build(); 它在“Android.Gms.Games.API”下给出错误 堆栈溢出线程中提到的所有事情

我想将我的xamarin android应用程序与google play services排行榜和成就进行集成。我不知道如何将下面的代码从转换为c

我试着转换如下的东西

GoogleApiClient api = new GoogleApiClient.Builder(this)
           .AddApi(Android.Gms.Games.API)
           .Build();
它在“Android.Gms.Games.API”下给出错误

堆栈溢出线程中提到的所有事情都不起作用。看起来这些东西大部分都不推荐了

请建议是否有其他与排行榜整合的简便方法

编辑:进行了更改,现在给出以下错误


您可以通过以下方式访问
GoogleClientAPI

var googleClientAPI = new GoogleApiClient.Builder(Application.Context).AddApi(XXX).Build();
使用阻塞连接作为快速测试的示例: 注意:此假设您已注册应用程序,否则您将收到致命的开发人员错误。。。看见
由于您需要访问排行榜和成就,请确保已添加以下软件包:

  • Xamarin.GooglePlayServices.Games
  • Xamarin.GooglePlayServices.Identity
这些将自动包括
.Base
.Base


  • 添加包后要查看的名称空间:


酷。看起来我已经添加了所有的引用。我没有按照你提到的语法。我现在好了。谢谢你…我按照你说的做了改变。现在它给出了错误。请参见问题中的“我的编辑”。@RajKarri我添加了一个示例,请确保您已注册应用程序(请参见备注)
var googleClientAPI = new GoogleApiClient.Builder(Application.Context).AddApi(XXX).Build();
var client = new GoogleApiClient.Builder(Application.Context)
                                .AddApi(GamesClass.API)
                                .AddScope(GamesClass.ScopeGames)
                                .Build();
Task.Run(() => {
    client.BlockingConnect();
    System.Diagnostics.Debug.WriteLine(client.IsConnected);
});
using Android.Gms.Common.Apis;
using Android.Gms.Games.LeaderBoard;
using Android.Gms.Games.Achievement;