2

Attempt History

It could be a duplicate for this I followed all the suggestions in the comments, none of them helped resolve. So i have a duplicate question with some more additional information.

Issue

Whenever I run my app with the below mentioned spec of AVD, i get a logcat like

Google Play services out of date. Requires 7571000 but found 6774470. 

Details

These are the version of stuffs i have. Please let me know if need any info, currently I'm blocked hope any one from GCM team can help me resolve this.

Android Studio 1.3 RC3

Gradle

root/gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0-beta3'
        classpath 'com.google.gms:google-services:1.3.0-beta1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

app/gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 22
    buildToolsVersion "21.0.1"

    defaultConfig {
        applicationId "com.mysample.gcm"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            //runProguard false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-gcm:7.5.0'
    compile 'com.android.support:appcompat-v7:+'
}

AVD Info

enter image description here

SDK Info

enter image description here enter image description here

  • EDIT: Added complete graddle files
  • EDIT2: Missed mentioning that these samples are an excerpt from Official sample for GCM.
Community
  • 1
  • 1
raksja
  • 3,969
  • 5
  • 38
  • 44

1 Answers1

2

The problem is not with your project or your code, you just need to upgrade Google Play Services in your emulator.

You can easily prompt an upgrade in the onCreate() override for your Activity (and you should have this code in your project for end users as well).

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (status != ConnectionResult.SUCCESS) {
    if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
        GooglePlayServicesUtil.getErrorDialog(status, this,
                100).show();
    } 
}

You can check the result in onActivityResult():

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 100){
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    }

}
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
  • +1 for quick response and suggestion. github.com/googlesamples/google-services/blob/master/android/… exactly what I have, but since its running in emulator, update play services not working, even though prompt shows up. – raksja Jul 21 '15 at 06:07
  • @techastute Ahh, well there's the problem. Unfortunately there is nothing you can do except for getting a successful upgrade of Google Play Services. Just know that it's strictly an emulator issue. If you can test on a device you won't have any issues. – Daniel Nugent Jul 21 '15 at 06:11
  • 1
    @techastute you might want to try [Genymotin](http://genymotion.com) + Installing GApps on them ? – Ye Lin Aung Jul 21 '15 at 07:40
  • @YeLinAung it looks like a worth try. But since i spent more than 3 hours trying to fix it, i would like to know what am i doing wrong? Also the process to install play service in Genymotin looks [tiresome](http://www.techrepublic.com/article/pro-tip-install-google-play-services-on-android-emulator-genymotion/). Have you used Genymotin+PlayService before? – raksja Jul 21 '15 at 09:00
  • 1
    @techastute Like Daniel said it's very likely that the emulator is having the lower version of Play Services ( That has been pretty problematic because some devices don't even come with Play Store and Google Apps ). However, I'd suggest to take a try with Genymotion. Better explanation about installing GApps on Genymotion can be found on [SO](http://stackoverflow.com/questions/17831990/how-do-you-install-google-frameworks-play-accounts-etc-on-a-genymotion-virt). Yes. I've been using Genymotion + Play Services for quite some time and it works perfectly. :) – Ye Lin Aung Jul 21 '15 at 09:28
  • U guys and Genymotin are awesome. +1 @YeLinAung for SO post, it was very straightforward. I will still leave this as a question to get some AVD related solution. – raksja Jul 21 '15 at 19:17
  • No AVD related solution, but Genymotion is better bet. – raksja Oct 02 '15 at 18:26