我正在开发使用Google Cloud Messaging服务的Xamarin Cross平台应用程序。因此,当我调用下面的方法时,出现异常“设备没有com.google.android.gsf软件包”。
我试图在Visual Studio Android模拟器(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)
{
}
最佳答案
Visual Studio模拟器默认没有安装它。因此,您需要安装Gapps CyanogenMod,其中包含运行诸如Push Notifications之类的东西所需的Google Apps。
为您的仿真器版本下载Gapps CyanogenMod。 (对于Visual Studio模拟器,您要选择HDPI / MDPI / TINY版本)。
下载完成后,请确保已加载模拟器。将zip文件拖放到模拟器中。系统将提示您安装。
按安装和关闭。然后它将复制,提取并安装服务。
然后再次启动Visual Studio模拟器。这可能意味着再次运行您的项目。但是,由于它需要在启动时进行一些配置,因此您的应用可能无法在首次模拟器加载时启动。您可能需要再次运行VS项目才能运行。
现在,您将不再收到Device does not have package com.google.android.gsf
错误。