设备没有com.google.android.gsf包(Visual Studio Android模拟器)

Par*_*iya 6 android-emulator google-cloud-messaging xamarin.forms visual-studio-2015

我正在开发Xamarin Cross平台应用程序,我正在使用Google Cloud Messaging服务.因此,当我调用下面的方法时,我得到异常"设备没有包com.google.android.gsf".我试图在Visual Studio Android Emulator(MarshMallow Android 6.0 -API 23)和(Lollipop Android 5.1 - API 22)上运行这个项目

那么如何克服这个问题呢.提前致谢.

      try {
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            // Register for push notifications
            Log.Info("MainActivity", "Registering...");
            GcmClient.Register(this, Constants.SenderID);
        }
        catch(Exception ex)
        {

        }
Run Code Online (Sandbox Code Playgroud)

Ada*_*ley 6

默认情况下,Visual Studio仿真器没有安装它.因此,您需要安装Gapps CyanogenMod,其中包含运行推送通知等所需的Google Apps.

  1. 下载Gapps CyanogenMod为您的模拟器版本.(对于想要选择HDPI/MDPI/TINY版本的visual studio模拟器).

  2. 下载后请确保已加载模拟器.将zip文件拖放到模拟器中.系统将提示您安装.

在此输入图像描述

  1. 按安装和关机.然后它将复制,提取和安装服务.

在此输入图像描述

  1. 然后再次启动Visual Studio模拟器.这可能意味着再次运行您的项目.但是,因为它需要在启动时配置一些内容,您的应用程序可能无法在第一个模拟器加载时启动.您可能需要再次运行VS项目才能运行.

在此输入图像描述

现在您将不再收到Device does not have package com.google.android.gsf错误.


joe*_*joe 0

是的,一些 Google 提供的模拟器映像没有它,其他的则有。如果我使用 Google 提供的模拟器,我通常使用“Google APIs Intel Atom (x86)”图像。对于其他模拟器,可能有效。