Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 此应用程序赢得了';除非更新Google Play services错误,否则无法运行_Android_Google Maps_Android Emulator_Google Play_Google Play Services - Fatal编程技术网

Android 此应用程序赢得了';除非更新Google Play services错误,否则无法运行

Android 此应用程序赢得了';除非更新Google Play services错误,否则无法运行,android,google-maps,android-emulator,google-play,google-play-services,Android,Google Maps,Android Emulator,Google Play,Google Play Services,我现在有点迷路了。 我正在使用谷歌地图实现一个Android应用程序 为了让它工作,我遵循了一些非常有效的教程。但我还是坚持这一点: 为了解决这个问题,我发现了一些技巧,或者说为了解决这个问题,你必须对模拟器进行特殊配置,下面是我的: 并在模拟器上安装一些.apk 魔术应该完成,地图应该出现,这不是我的情况 我检查了我的附加设备是否安装良好: 这是我的AndroidManifest: <?xml version="1.0" encoding="utf-8"?> <man

我现在有点迷路了。 我正在使用谷歌地图实现一个Android应用程序

为了让它工作,我遵循了一些非常有效的教程。但我还是坚持这一点:

为了解决这个问题,我发现了一些技巧,或者说为了解决这个问题,你必须对模拟器进行特殊配置,下面是我的:

并在模拟器上安装一些.apk

魔术应该完成,地图应该出现,这不是我的情况

我检查了我的附加设备是否安装良好:

这是我的AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="mypack"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-sdk android:minSdkVersion="16"/>

    <permission android:name="mypack.permission.MAPS_RECEIVE"
                android:protectionLevel="signature"/>
    <uses-permission android:name="mypack.permission.MAPS_receive"/>

    <!-- Permission pour utiliser la connexion internet -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Permission permettant de vérifier l'état de la connexion -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Permission pour stocker des données en cache de la map -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true" />

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="MYKEY" />

        <meta-data android:name="com.google.android.gms.version"
                   android:value="@integer/google_play_services_version" />

        <activity android:name="Home"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>
以及相应的布局:

<?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 xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:name="com.google.android.gms.maps.MapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent" />
</LinearLayout>


希望找到一些修复或我在这里错过的东西,提前感谢您。

在Android SDK管理器中,您必须在“Android 4.4.2(API 19)”下安装“Google API(x86系统映像)”。退出Eclipse并重新启动它

然后在AVD管理器中创建一个新的android虚拟设备,并选择“Google API x86(Google Inc.)-API Level 19”作为目标。选中“使用主机GPU”以确保地图绘制速度加快


就是这样,这个新的仿真器将预装播放服务,它将运行得更快,因为它是一个x86映像。

使用android studio,唯一帮助我的是将gradle文件中的google播放服务版本从上一个版本减少到以下版本:

compile 'com.google.android.gms:play-services:4.2.+'

(当然,这是一个临时的“旁路”,使您能够继续运行)

我只有在使用android Studio中的android emulator时才遇到这个问题。 我通过向gradle:app添加谷歌服务插件解决了这个问题

apply plugin: 'com.google.gms.google-services'
然后是依赖关系 加

以前我用的是

compile 'com.google.android.gms:play-services:9.4.0'

但它给出了一个错误,即存在版本不匹配,建议使用com.android.gms 9.0.0版。我在尝试构建android 7.0时遇到了相同的错误。我在6.0下重建,没有任何问题。恢复1个API级别可能也会帮助您。

我也有相同的错误。通过同时更新android Studio来修复它s相关的Android SDK工具。

我遇到了一个问题,遇到了这个错误,点击“更新”按钮什么也没做,它被卡在了一个循环中,工作如下(在Android Studio中):

  • 转到工具>Android>SDK管理器
  • 选中“显示包详细信息”选项
  • 在您想要的Android版本下(我现在使用的是7.1.1),选中“谷歌播放英特尔x86 Atom系统映像”
  • 点击Apply/OK并让映像安装
  • 现在转到工具>Android>AVD管理器
  • 创建虚拟设备
  • 选择带有Google Play徽标的设备之一:
  • 在新的emulator中运行你的应用程序。当你出现错误时,你现在可以点击“更新”,通过你设备上的Play Store更新Google Play服务,并和平地测试你的应用程序

为了省去配置不支持google play的仿真器的麻烦,请始终使用带有播放图标的仿真器

如图所示:播放图标出现在Playstore行下

安装google play兼容仿真器后…再次在仿真器中运行你的应用程序…当你收到通知“除非……”时,单击通知并按照屏幕提示:“使用gmail帐户登录…电子邮件和密码等。”“,一旦您同意谷歌许可证,您将获得谷歌播放更新屏幕:

更新你的google play并再次启动你的应用程序。 还要确保你的应用程序级gradle和gradle中有谷歌依赖项:

应用程序级渐变 build.gradle(模块:应用程序)

项目级梯度 “构建,梯度(项目:AppName)”

依赖关系{

    classpath 'com.google.gms:google-services:3.2.1'
}

虽然提供的答案适用于模拟器,但在真实设备上这可能是一个真正的问题,这些解决方案在真实设备上不起作用。这可能发生在具有过时版本的Google Play Services的旧设备上

为了解决这个问题,Google Play服务库提供了一组API来检查Google Play服务的可用性,主要是该类提供了一些方法来处理可用性问题,例如过时的版本

现在,要检测设备是否有可用的Google Play服务,我通常要做的是创建一个助手方法来运行检查

private boolean checkPlayServices(){
    GoogleApiAvailability gaa = GoogleApiAvailability.getInstance();
    int result = gaa.isGooglePlayServicesAvailable(getApplicationContext());

    if(result != ConnectionResult.SUCCESS){
        if(gaa.isUserResolvableError(result)){
            gaa.getErrorDialog(this,result, REQUEST_PLAY_SERVICES_RESOLUTION).show();
        }

        return false;
    }

    return true;
}
此帮助器方法通过检查从
isGooglePlayServicesAvailable
返回的错误代码来检查Google Play服务是否可用。然后调用
isUserResolvableError
以确定用户是否可以解决错误(例如,通过更新Google Play服务)。如果可以解决,则会显示一个对话框,供用户确认他希望系统解决错误。然后在活动的
onCreate
方法上调用它,我将按如下方式运行该检查

//I normally assume Google Play services is available
private boolean playServicesAvailable = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map_selector);

    //check for rare case where Google Play Services is not available
    playServicesAvailable = checkPlayServices();

    if(!playServicesAvailable){
        //hide UI elements and turn off features that rely on Google Play Services
    }
}

希望它能帮助Android Studio 3中的一些人,转到
工具->SDK管理器安装Google Play services

我通过以下方式解决了这个问题:

1-确保在SDK工具中安装了“Google Play Services”,如下图所示:

2-确保AndroidManifest.xml文件包含以下行:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
注意:您可能需要将play services地图的版本从17更改为最新版本,但最新版本是2019年8月的17

如下图所示:

不要忘记重建项目(如果使用flift,请在terminalflift clean中执行此命令)

然后您将看到地图正在emulator上运行:


可能重复的事实是,我按照本应修复此错误的步骤进行操作,但没有任何效果。因此,我想知道我可能遗漏了什么。您的问题有点误导,因为该错误是由于尝试在模拟器中运行GPS应用程序而导致的,无论哪种方式,这都可能有助于您的权利n
private boolean checkPlayServices(){
    GoogleApiAvailability gaa = GoogleApiAvailability.getInstance();
    int result = gaa.isGooglePlayServicesAvailable(getApplicationContext());

    if(result != ConnectionResult.SUCCESS){
        if(gaa.isUserResolvableError(result)){
            gaa.getErrorDialog(this,result, REQUEST_PLAY_SERVICES_RESOLUTION).show();
        }

        return false;
    }

    return true;
}
//I normally assume Google Play services is available
private boolean playServicesAvailable = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map_selector);

    //check for rare case where Google Play Services is not available
    playServicesAvailable = checkPlayServices();

    if(!playServicesAvailable){
        //hide UI elements and turn off features that rely on Google Play Services
    }
}
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
classpath 'com.google.android.gms:play-services-maps:17.0.0'