After updating the Google Play service to version 13, I received an error

How can I solve this error?

Called: java.lang.illegalargumentexception 11-01 11: 08: 12.845: E / AndroidRuntime (28885): called: java.lang.IllegalStateException: the metadata tag in your AndroidManifest.xml application does not have the correct value. Expected 4030500 but found 0. You should have the following declaration inside 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 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 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 
+70
java android google-play-services
Nov 01. '13 at 9:13
source share
8 answers

You need to add the following to the 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 message, as well as in Configuring Google Play Services (thanks to Brais Gabin)

+154
Nov 01 '13 at 9:24
source share

@ Benoit's answer has an exact solution, which I answer with additional knowledge:

1. , since Benoit's answer added the following AndroidManifest.xml internal application tag

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

2. we can directly add the version code, for example

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

4030500 is the version code that is stored internally

Google-services-services_lib> Res> Values> version.xml

how

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

Conclusion: the latest google play services require a version name, which must be specified using <meta-data .. /> inside AndroidManifest.xml

Note: I would highly recommend using the 1st method.

+23
Nov 06 '13 at
source share

A few things have changed since you asked this question. If you use Google Play 7.0 or later, Gradle will automatically merge the manifest and include the necessary metadata for you.

Quoting Ian Lake :

(...) Google Play Services 7.0 also has another time-saving feature if you use Gradle: it automatically turns on

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

in your AndroidManifest.xml for you - no need to manually add it! A great example of a simple merging manifest, where libraries can add the necessary metadata, receivers, permissions, and everything else they needed was another thing to forget!

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

+4
Aug 16 '15 at 21:24
source share

Just remember to add below two metadata tags to your AndroidManifest.xml application

 <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.

+2
Apr 08 '15 at 19:41
source share

I imported my existing project from Eclipse into Android Studio, and the Eclipse Integers.xml project contained a hard-coded value, as shown below.

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

causes a version conflict with the latest version of Play Services created by Android Studio. after removing this line from Integers.xml it started working for me.

+2
Jul 08 '15 at 12:06
source share

I created the file "version.xml" in the res / values ​​folder of the included copy of google services and inserted 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 solved my problem

+1
Dec 6 '13 at 2:02
source share

If you still have an error, try this.

it worked for me

 <meta-data tools:replace="android:value" android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 
+1
Sep 10 '18 at 0:26
source share

Add <meta-data> after closing the <application> . It solved my problem

-one
Feb 21 '14 at 17:36
source share



All Articles