Android Studio 模拟器:除非您更新 google 播放服务,否则应用不会 运行

Android Studio Emulator: App won't run unless you update google play services

我正在构建一个使用 google 地图的应用程序 api.The 该应用程序的第一个 activity 是一个地图 activity,它拒绝 运行根据我在标题中所述的错误。

我已对 build.gradle 进行了大量修改,试图解决该问题;基于我在本网站上找到的其他解决方案。

但我想我可能让情况变得更糟:这就是我的 build.gradle 的样子:

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.navigation.dixongardens.ben.bensgardens"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:28.0.0-alpha1'
    compile 'com.google.android.gms:play-services-maps:11.6.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    // androidTestImplementation 'com.android.support.test:runner:1.0.1'
    // androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.google.maps.android:android-maps-utils:+'
    compile 'com.google.android.gms:play-services:11.8.+'
    compile 'com.android.support:design:26.0.0-alpha1'
}

有人可以帮助指导我 build.gradle 有什么问题吗?我对 google 服务正常工作需要哪些依赖项感到困惑。

这不是您的应用程序的问题,而是您的模拟器的问题。您需要更新您正在使用的模拟器 运行/下载新的系统映像并从中创建一个模拟器。

例外情况告诉您 Google 地图需要比您设备上当前 运行 版本更新的 Google Play 服务版本。有时会在通知下有一个link更新google播放服务。 (在 google 地图视图的应用程序中)

您无需执行任何操作,只需点击显示上述消息的通知即可。然后google播放服务会自动更新。简单