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

时间:2016-04-28 07:11:54

标签: visual-studio-2015 android-emulator google-cloud-messaging xamarin.forms

我正在开发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)
        {

        }

2 个答案:

答案 0 :(得分:6)

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

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

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

  3. enter image description here

    1. 按安装和关机。然后它将复制,提取和安装服务。
    2. enter image description here

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

        现在您将不再收到<?php include 'config.php'; session_start(); //echo "hii"; if(isset($_POST['s_submit'])){ $email=$_POST['s_email']; //echo $email; $pass=$_POST['s_password']; $sql=mysqli_query($con,"INSERT INTO personal_info (`email`,`password`,`first_time_login`)VALUES('".$email."','".$pass."','0')"); header('location:index.php?$message="form successfully submitted you can login"'); } if(isset($_POST['login'])){ $email=$_POST['email']; $pass=$_POST['password']; $q=mysqli_query($con,"SELECT * FROM personal_info WHERE email='".$email."' AND password='".$pass."' "); $row_fetch=mysqli_fetch_assoc($q); echo $row_fetch['first_name']; $count=mysqli_num_rows($q); if($count>0){ $id=$row_fetch['id']; $_SESSION['id']=$id; //$id=mysqli_insert_id($conn); if($row_fetch['first_time_login']=="1") { header('location:index.php#'); } else{ header('location:user.php'); } } else{ header('location:index.php?loginerr="invalid user"'); } } mysqli_close($con); ?> 错误。

答案 1 :(得分:0)

是的,某些Google提供的模拟器图片没有,其他人则没有。我通常使用&#34; Google API Intel Atom(x86)&#34;图片,如果我使用谷歌提供的模拟器。对于其他模拟器this可能有效。