【问题标题】:Google Play Services Error on emulator模拟器上的 Google Play 服务错误
【发布时间】:2017-10-07 22:21:52
【问题描述】:

我正在尝试检查我的应用在模拟器上的运行情况,但是当我尝试使用 google 登录选项登录时,我的应用只显示一个 Toast,表明存在“Google Play 服务错误”。

当我进入登录屏幕时,会出现更新对话框,上面没有任何文字。

我尝试将我的 google play 服务更新到最新版本,但没有帮助。有谁知道如何在我的模拟器上使用 Google 登录的解决方案?

这是我的构建 gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'

android {
signingConfigs {
    config {

    }
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.fromworldwide.from"
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 19
    versionName "2.8"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/DEPENDENCIES'
    exclude '.readme'
}
buildTypes {
    release {
        debuggable false
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config

    }
    debug {
        debuggable true
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
useLibrary 'org.apache.http.legacy'
}   

buildscript {
repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'io.fabric.tools:gradle:1.+'

}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
testCompile 'junit:junit:4.12'

compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.firebase:firebase-storage:11.0.2'
compile 'com.google.firebase:firebase-invites:11.0.2'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'

compile 'com.google.android.gms:play-services-basement:11.0.2'
// Mandatory
compile 'com.google.android.gms:play-services-location:11.0.2'


} 
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.gms.google-services'

allprojects {
repositories {
    maven { url "https://jitpack.io" }
}
}

【问题讨论】:

    标签: android android-emulator google-play-services


    【解决方案1】:

    我认为您遗漏了 how you can test your app 文档中提到的内容。

    要在使用 Google Play 服务 SDK 时测试您的应用,您必须使用 要么:

    • 运行 Android 4.0 或更高版本并包含 Google Play 商店的兼容 Android 设备。
    • 带有AVD 的Android 模拟器运行基于Android 4.2.2 或更高版本的Google API 平台。

    另外你需要Add Google Play Services to Your Project

    使 Google Play 服务 API 可用于您的应用:

    1. 打开应用程序模块目录中的 build.gradle 文件。

    注意:Android Studio 项目包含顶级 build.gradle 文件和每个模块的 build.gradle 文件。一定要编辑 应用程序模块的文件。有关 Gradle 的更多信息,请参阅Building Your Project with Gradle

    1. 在最新版本的播放服务的依赖项下添加新的构建规则。例如:

      apply plugin: 'com.android.application'

      ...
      
      dependencies {
          compile 'com.google.android.gms:play-services:11.4.2'
      }  
      

    确保每次使用 Google Play 服务时都更新此版本号 已更新。

    注意:如果您的应用程序中的方法引用数量超过65K limit,您的应用程序可能无法编译。您也许可以减轻 通过仅指定特定来编译您的应用程序时出现此问题 您的应用使用的 Google Play 服务 API,而不是全部。为了 有关如何执行此操作的信息,请参阅Selectively compiling APIs into your executable

    1. 保存更改并点击工具栏中的将项目与 Gradle 文件同步

    【讨论】:

      【解决方案2】:

      创建模拟器时,需要使用(Google Play)Target列的系统镜像:

      包含 (Google API) 的目标将不起作用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-08-26
        • 2017-03-01
        • 2015-08-02
        • 2015-08-14
        • 2019-01-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多