【发布时间】:2015-08-29 09:28:25
【问题描述】:
我无法通过 Android Studio 中的模拟器使用 Google Play 服务。我给你我的 build.gradle 和 manifest 文件:
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
repositories {
mavenCentral()
}
defaultConfig {
applicationId "fr.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:multidex:1.0.1'
}
我的 AndroidManifest 的一部分(我没有显示所有活动):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings" >
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>
</manifest>
在 xml 中,我只有 google 按钮:com.google.android.gms.common.SignInButton
当我启动我的应用程序时,当我到达包含按钮的活动时,我收到以下消息:“除非您更新 Google Play 服务,否则该应用程序将无法运行”。我也有(我尝试了一些解决方案)“如果没有 Google Play 服务,此应用将无法运行,而您的手机中缺少这些服务”。
我发现了一些关于这个问题的问题,但总是说最后一个模拟器没有这个问题。但是在 android studio 上使用默认的 Nexus 5 (API 22) 模拟器会给我这些错误。因此,我尝试安装最后一个 apk google play services 文件,安装成功后,我启动应用程序并出现此错误:“该应用程序依赖于您的设备不支持的 Google Play 服务。请联系制造商寻求帮助。”我还尝试使用我创建的虚拟设备,使用 API 22 和 23,但我遇到了同样的错误。
我不明白,因为我认为 Google Play 服务的错误在最后一个 API 上已经不存在了。
感谢您的帮助。
【问题讨论】:
标签: android android-studio android-emulator