70

How can I resolve this error?

Caused by: java.lang.illegalargumentexception 11-01 11:08:12.845: E/AndroidRuntime(28885): 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 element:


google-play-services_lib Manifest:

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

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

</manifest>


public void loginGooglePlus() {
    aHelper.setup(this, GameHelper.CLIENT_APPSTATE | GameHelper.CLIENT_GAMES);
    mHelper = aHelper.getAppStateClient();
    //crash is here
    mHelper.connect();
}


Full error log:

11-01 11:38:13.507: E/AndroidRuntime(31297): FATAL EXCEPTION: main
11-01 11:38:13.507: E/AndroidRuntime(31297): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.application.android.aja/com.company.application.android.aja.BeetleBattleAndroidActivity}: 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" />
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2077)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.ActivityThread.access$600(ActivityThread.java:134)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.os.Looper.loop(Looper.java:154)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.ActivityThread.main(ActivityThread.java:4624)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at java.lang.reflect.Method.invokeNative(Native Method)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at java.lang.reflect.Method.invoke(Method.java:511)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:965)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:732)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at dalvik.system.NativeStart.main(Native Method)
11-01 11:38:13.507: E/AndroidRuntime(31297): 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" />
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.google.android.gms.internal.de.connect(Unknown Source)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.google.android.gms.appstate.AppStateClient.connect(Unknown Source)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.company.application.android.aja.BeetleBattleAndroidActivity.loginGooglePlus(BeetleBattleAndroidActivity.java:153)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at com.company.application.android.aja.BeetleBattleAndroidActivity.onCreate(BeetleBattleAndroidActivity.java:143)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.Activity.performCreate(Activity.java:4509)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
11-01 11:38:13.507: E/AndroidRuntime(31297):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041)
11-01 11:38:13.507: E/AndroidRuntime(31297):    ... 11 more
MattDMo
  • 100,794
  • 21
  • 241
  • 231
Igor Kostenko
  • 2,754
  • 7
  • 30
  • 57
  • 1
    I also have this since the latest Android SDK Tools update that is released today – Ivo Nov 01 '13 at 09:26
  • 8
    It helps if you read the full error message, because it is actually pretty clear in terms of what it is expecting. You can copy-paste it directly in your app project's manifest. – MH. Nov 01 '13 at 09:35
  • 2
    Or install and use the "Google Play Services for Froyo" – Tim Nov 01 '13 at 16:26

8 Answers8

154

You need to add the following in your manifest:

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

EDIT:

This information can be found in the logcat error msg as well as on Setting Up Google Play Services (Thanks Brais Gabin)

Sam R.
  • 16,027
  • 12
  • 69
  • 122
Benoit
  • 4,549
  • 3
  • 28
  • 45
  • 4
    @ErichDouglass yes, it's. [Set Up a Project that Uses Google Play Services](http://developer.android.com/google/play-services/setup.html#Setup). An answer with a source reference is ALWAYS better ;). – Brais Gabin Dec 03 '13 at 12:30
  • Thx for the source, but if you look closely to the logcat you can also get the information there – Benoit Dec 05 '13 at 09:30
  • 2
    @Benoit Hi, I followed this answer and I got a logcat error saying **Using google play services requires a metadata tag with the name "com.google.android.gms.games.APP_ID" in the application tag of your manifest** – Ogen Jan 17 '14 at 01:24
  • There are more metadata tags, this one looks like you are using something specific to the games part of the services. check their documentation – Benoit Jan 17 '14 at 09:55
  • You need to have both in the manifest. 1.for the Goolge API Key 2.for google_play_services_version. – Raj Trivedi Jan 29 '14 at 10:00
  • @Benoit can u tell me i update my sdk to 5.0 lollipop and now import latest google play service lib in my workspace and added in projedct to use map now getting error 02-02 01:34:49.659: E/AndroidRuntime(10438): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the element: – Erum Jan 31 '15 at 20:35
23

@Benoit'a answer has exact solution i am answering with additional knowledge:

1. one way as Benoit answered is add following inside application tag of AndroidManifest.xml

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

2. we can directly add the version code like

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

4030500 is version code which is stored inside

google-play-services_lib>res>values>version.xml

Like

<integer name="google_play_services_version">4030500</integer>

Conclusion: Latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml

Note: I would strongly recommend to use 1st way

Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71
  • @JanshairKhan `google-play-services_lib>res>values>version.xml` – Tarsem Singh Dec 03 '13 at 12:00
  • Previosly I was having this meta data tag in manifest: android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyC2IpI158TISY8sV6DyJUkIFv-L_kGpkwE" /> I was given this error.The meta-data tag in your app's AndroidManifest.xml does not have the right value. i changed the meta tag now i am giventhis error: Caused by: java.lang.RuntimeException: API key not found. Check that is in the element of AndroidManifest.xml – ozmank Feb 15 '14 at 21:10
4

A few things changed since you asked that question. If you're using Google Play services 7.0 or newer, Gradle will automatically merge manifests and include the required meta-data for you.

Citing Ian Lake:

(...) Google Play services 7.0 also has one other time saving feature if you're using Gradle: it automatically includes the

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

entry in your AndroidManifest.xml for you - no need to manually add it! Perfect example of simple Manifest merging where libraries can add required meta-data, receivers, permissions, and anything else they made need - one less thing to forget!

Note: this does not apply to the full play-services or play-services-all-wear AARs - only the granular AARs have this built in.

EyesClear
  • 28,077
  • 7
  • 32
  • 43
2

I did create a file "version.xml" in the res/values folder of the included copy of google services and pasted the code:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
<integer name="google_play_services_version">4030500</integer>
</resources>

the original copy missed the file and it did solve my problem

2

Just make sure to add the below two meta-data tags to 'your' application's AndroidManifest.xml

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

This solution worked for me.

vaaa
  • 21
  • 1
  • This answer doesn't add anything meaningful to the already existing and accepted answer of more than an year ago. – Mephy Apr 08 '15 at 19:55
  • Yes , may be . But I followed the post and i got confused. We have inside google play service lib's manifest file too. Someone, who is a beginner may get confused whether to add this tag in own app's androidManifest.xml or not(as it is already available in google play service lib which is added to our project lib, may lead to duplication). I hope these two statements will give more clarification on existing and accepted answer. :) – vaaa Apr 08 '15 at 21:58
  • @vaaa: You'd do better to work that explanation into the answer organically; comments are intended to be fairly disposable. – Nathan Tuggy Apr 09 '15 at 01:12
  • Atleast, I have posted a better stuff than what is being posted as comment right away...this blog is mean't to post your coding experiences ,it may be in any form comments or answer. :) – vaaa Apr 09 '15 at 06:43
2

I imported my existing project from Eclipse to Android Studio, In Eclipse project Integers.xml was containing hardcoded value as following

<integer name="google_play_services_version">5089000</integer>

causing version conflict with latest version of Play Services being built by Android Studio. after removing this line from Integers.xml it started working for me.

Aqib Mumtaz
  • 4,936
  • 1
  • 36
  • 33
1

If you still having error try this one.

it worked for me

<meta-data
    tools:replace="android:value"
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Ahmed Mujtaba
  • 744
  • 5
  • 16
-1

Add <meta-data>after closing <application> tag. This solved my problem

Assasin_ng
  • 31
  • 1
  • 5