Tomas Maksimavicius
Tomas Maksimavicius

Reputation: 414

Google Play Services Error on emulator

I am trying to check how my app is working on emulator, but when I try to sign in with google sign in options my app just shows a Toast that there is "Google Play Services error."

Also when I go to login screen, the Update dialog appears with nothing written on it.

I tried to update my google play services to latest version, but it did not help. Does anyone know a solution to how I can login with Google on my Emulator?

Here is my build 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" }
}
}

enter image description here

Upvotes: 1

Views: 1730

Answers (2)

keccs
keccs

Reputation: 163

When creating the emulator, you need to use a system image that has (Google Play) in the Target column:

enter image description here

The targets containing (Google APIs) will not work.

Upvotes: 1

MαπμQμαπkγVπ.0
MαπμQμαπkγVπ.0

Reputation: 6729

I think you are missing something that was mentioned in the documentation on how you can test your app.

To test your app when using the Google Play services SDK, you must use either:

  • A compatible Android device that runs Android 4.0 or higher and includes Google Play Store.
  • The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher.

Also you need to Add Google Play Services to Your Project

To make the Google Play services APIs available to your app:

  1. Open the build.gradle file inside your application module directory.

Note: Android Studio projects contain a top-level build.gradle file and a build.gradle file for each module. Be sure to edit the file for your application module. See Building Your Project with Gradle for more information about Gradle.

  1. Add a new build rule under dependencies for the latest version of play-services. For example:

    apply plugin: 'com.android.application'

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

Be sure you update this version number each time Google Play services is updated.

Note: If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them. For information on how to do this, see Selectively compiling APIs into your executable.

  1. Save the changes and click Sync Project with Gradle Files in the toolbar.

Upvotes: 0

Related Questions