Android Studio 1.3 RC3. Google Play services out o

2019-07-20 18:53发布

问题:

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

SDK Info

  • EDIT: Added complete graddle files
  • EDIT2: Missed mentioning that these samples are an excerpt from Official sample for GCM.

回答1:

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);
    }

}