C# Xamarin应用程序赢得';没有google play服务就无法运行

C# Xamarin应用程序赢得';没有google play服务就无法运行,c#,android,.net,google-maps,xamarin,C#,Android,.net,Google Maps,Xamarin,我是Xamarin Android的新手。我试图在我的应用程序上显示一个基本的谷歌地图。我为谷歌地图API设置了API密钥等。但是,当我运行模拟器时,它会显示一条消息“没有google play服务,应用程序将无法运行” 我已经使用android sdk管理器安装了所有软件包/sdk,我正在尝试使用API级别22(android 5.0棒棒糖) 下面的代码用于初始化谷歌地图(从xamarin示例下载) 谁能告诉我我在这里错过了什么 using System; using

我是Xamarin Android的新手。我试图在我的应用程序上显示一个基本的谷歌地图。我为谷歌地图API设置了API密钥等。但是,当我运行模拟器时,它会显示一条消息“没有google play服务,应用程序将无法运行”

我已经使用android sdk管理器安装了所有软件包/sdk,我正在尝试使用API级别22(android 5.0棒棒糖)

下面的代码用于初始化谷歌地图(从xamarin示例下载)

谁能告诉我我在这里错过了什么

      using System;
      using Android.App;
      using Android.Content;
      using Android.Gms.Maps;
      using Android.Gms.Maps.Model;
      using Android.Runtime;
      using Android.Views;
      using Android.Widget;
      using Android.OS;

      namespace App2
      {
       [Activity(Label = "App2", MainLauncher = true, Icon = "@drawable/icon")]
      public class MainActivity : Activity, IOnMapReadyCallback
      {
        private GoogleMap _gMap;
        protected override void OnCreate(Bundle bundle)
        {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);
        GetMap();
    }

    private void GetMap()
    {

        if (_gMap == null)
        {
            FragmentManager.FindFragmentById<MapFragment>(Resource.Id.map).GetMapAsync(this);
        }
    }

    public void OnMapReady(GoogleMap map)
    {
        _gMap = map;
    }
  }
}
使用系统;
使用Android.App;
使用Android.Content;
使用Android.Gms.Maps;
使用Android.Gms.Maps.Model;
使用Android.Runtime;
使用Android.Views;
使用Android.Widget;
使用Android.OS;
名称空间App2
{
[活动(Label=“App2”,MainLauncher=true,Icon=“@drawable/Icon”)]
公共类main活动:活动,IOnMapReadyCallback
{
私人谷歌地图(gMap),;
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
//从“主”布局资源设置视图
SetContentView(Resource.Layout.Main);
GetMap();
}
私有void GetMap()
{
如果(_gMap==null)
{
FragmentManager.FindFragmentById(Resource.Id.map).GetMapAsync(this);
}
}
已于4月1日公开作废(谷歌地图)
{
_gMap=地图;
}
}
}
Main.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.MapFragment" />

Android Mainfest

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="App2.App2" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<application android:label="App2" android:icon="@drawable/Icon">
    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCKBrF-_IrAQlkUyFG7GT4qgEJ7qOgyNRI" />
</application>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<!-- We need to be able to download map tiles and access Google Play Services-->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allow the application to access Google web-based services. -->
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Google Maps for Android v2 will cache map tiles on external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Google Maps for Android v2 needs this permission so that it may check the connection state as it must download data -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- These are optional, but recommended. They will allow Maps to use the My Location provider. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


这似乎是因为设备,或者在本例中是模拟器,没有安装Google Play服务。Android应用程序中的软件包只提供对Google Play服务的访问,Google Play服务通常安装在设备本身上。从这个意义上讲,Google Play服务更像是一个共享运行时

要解决此问题,您应该能够按照以下步骤在模拟器上安装Google Play服务


我希望这有帮助

看起来您试图在未安装Google Play服务的模拟器映像上运行应用程序

首先也是最重要的,我总是建议使用物理设备进行测试,但如果您需要测试各种API级别,而您没有设备,那么使用模拟器就足够了

如果您使用的是谷歌AVD,那么您可以使用已经包含谷歌播放服务的AVD

如果你使用的是Xamarin Android播放器,那么你可以使用上面提到的@clb。但是,请记住,Xamarin Android Player是预览软件,不受官方支持。如果这是您在安装Google Play服务时遇到问题的模拟器,那么您最好的支持选项是。(该指南当前显示了错误的日志位置,现在可以通过(Windows)右键单击底部栏(Mac)并单击“帮助”菜单>“生成错误报告”(Generate Bug Report)来获取这些日志-日志将压缩到桌面上)


如果您仍然有问题,那么请让我知道您使用的是什么模拟器,我会看看是否可以进一步提供帮助

正如其他人所说,问题似乎在于模拟器上没有安装Google Play服务(也称为Google API)。这里有一个链接,指向我编写的教程,向您展示如何做到这一点。还有一段视频:

你好,clb,谢谢回复。我按照您的指示下载了相应的zip文件,但问题是我无法将其拖放到播放器上,当我尝试将zip拖放到播放器上时,它会给我一个圆圈(ban)图标。知道是什么引起的吗?嘿!我需要看看我是否能在我的系统上复制它。一旦我完成soHi Alan,我会回复这个帖子,我在一个物理设备上检查了我的应用程序&它工作正常。我想在Xamarin Player发布新版本之前,我现在必须接受它。另一种可能是,我运行的windows 10 Home没有hyper-v。如果您在此处发布一些信息,并提供指向您博客的链接,这将非常有用。链接可能会腐烂。关键是通过SDK管理器安装Google API,然后在设置设备时选择它——特别是在CPU/ABI部分。