43

Yesterday API 19 came out so I upgraded SDK and other (including Google Play Services) now this method:

private boolean isGooglePlayInstalled(){
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if(status == ConnectionResult.SUCCESS){
        return true;
    }else{
        ((Dialog)GooglePlayServicesUtil.getErrorDialog(status, this,10)).show();
    }
    return false;
}

Throws at line

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
Caused by: java.lang.IllegalStateException: The meta-data tag in your app's 
AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.
You must have the following declaration within the <application> element:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

How to fix that? I didnt have element

"com.google.android.gms.version"
in manifest before and it worked.

This is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sabatsoft.driveit"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.sabatsoft.driveit.activity.Start"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- other activities -->

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIza*********************************1MZI" />
    </application>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

</manifest>
SpeedEX505
  • 1,976
  • 4
  • 22
  • 33
  • 3
    Check this : http://stackoverflow.com/questions/19723811/after-google-play-service-update-to-version-13-i-got-an-error – Siddharth_Vyas Nov 01 '13 at 09:35
  • 2
    It works.. I guess my phone need an upgrade Google Play Services and Google Play hasnt recognized update yet. – SpeedEX505 Nov 01 '13 at 09:38
  • If you don't want to wait for the update of Google Play Services in the Play Store, grab the APK of Play Services 4.0 from one of the latest dumps: http://www.droid-life.com/2013/10/31/download-new-google-apps-from-the-nexus-5-dump-search-launcher-and-more/ (first download) – saschoar Nov 01 '13 at 11:39
  • I'm still downloading; But I noticed you don't have read permission read external storage in your manifest. – danny117 Nov 01 '13 at 16:00
  • The Google Play Services version management is a joke. One of the seething sores of the Google ecosystem. Shame on them for forcing this junk management on their developers. – Joshua Pinter Jun 16 '17 at 02:37

6 Answers6

64

This worked for me:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

Place this at the end of your manifest, after your Map API key meta-data tag. Since you check for GPlayServices availability in your onCreate method, such as:

// Check status of Google Play Services
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

// Check Google Play Service Available
try {
    if (status != ConnectionResult.SUCCESS) {
        GooglePlayServicesUtil.getErrorDialog(status, this, RQS_GooglePlayServices).show();
    }
} catch (Exception e) {
    Log.e("Error: GooglePlayServiceUtil: ", "" + e);
}

...then once you click the dialog box to update GPlayServices, you will be brought to the GPlayStore. Usually, I uninstall from the GPlayStore menu, then the option to update will be available. It should work after that.

BostonGeorge
  • 3,092
  • 1
  • 17
  • 12
  • 8
    This tag should be placed within tag instead of end of android manifest – ZeeShaN AbbAs Nov 26 '13 at 11:52
  • 1
    I do prefer this solution to @Saran because Google may have fixed bugs in later versions of their library. However I don't understand the usefulness of RQS_GooglePlayServices? Can I put any value? – redochka May 23 '14 at 14:37
21

Package contents comparison

The "google_play_services_froyo" lib project contains these com.google.android.gms packages:

  • appstate
  • auth
  • common
  • dynamic
  • games
  • gcm
  • internal
  • location
  • maps
  • panorama
  • plus

On the other hand, the new (rev. 13) "google_play_services" lib project has some additional packages within com.google.android.gms:

  • ads
  • appstate
  • auth
  • common
  • dynamic
  • games
  • gcm
  • internal
  • location
  • maps
  • panorama
  • plus
  • wallet

Plus, this package is found in the new (rev. 13) "google_play_services": com.google.ads!

AndroidManifext.xml comparison

The old (rev. 12) "google_play_services" had:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.gms"
    android:versionCode="3265130"
    android:versionName="3.2.65 (834000-30)" >

    <uses-sdk android:minSdkVersion="8"/>

</manifest> 

The newly introduced "google_play_services_froyo" lib project has:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.gms"
    android:versionCode="3225130"
    android:versionName="3.2.25 (761454-30)" >

    <uses-sdk android:minSdkVersion="8"/>

</manifest>

Conclusion

The "google_play_services_froyo" is functionally the same as the old (rev. 12) "google_play_services" lib project, so if you just want to keep your app compatible and don't care about the new APIs, just import the "google_play_services_froyo" in your project and you're good to go.

On the other hand, if you wanted to use the new (rev. 13) "google_play_services" lib project, once you import it, you have to add this to your apps manifest:

<application
...
  <meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
</application>

Hope this helped :)

Saran
  • 3,845
  • 3
  • 37
  • 59
  • 1
    For some reason 13 kept failing with a request to update Google Play Services. When I reverted to 12, it started working. So: Thanks! – EZDsIt Nov 05 '13 at 17:43
10

That happened to me yesterday. I just needed to add this in the manifest:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
gian1200
  • 3,670
  • 2
  • 30
  • 59
0

I solved my issue of the same with

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
vamshi palutla
  • 104
  • 1
  • 6
0

you have to add the following line in manifest file.
i hope it will work.

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
Nantha kumar
  • 153
  • 1
  • 3
  • 8
0

I faced this error because I referenced the original copy from SDK directory. Make sure that you first copy the library to android workspace and only reference it. In eclipse you can do it by checking "Copy projects into workspace" while importing the project.

Gary Wong
  • 9
  • 1
  • 2