[英]After Google Play Service update to version 13 I got an error
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.
引起:java.lang.illegalargumentexception 11-01 11:08:12.845:E / AndroidRuntime(28885):引起:java.lang.IllegalStateException:应用程序AndroidManifest.xml中的元数据标签没有正确的值。 Expected 4030500 but found 0. You must have the following declaration within the element:
预期4030500但找到0.您必须在元素中包含以下声明:
google-play-services_lib Manifest: google-play-services_lib清单:
<?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
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) 此信息可以在logcat错误消息中找到,也可以在设置Google Play服务中找到 (感谢Brais Gabin)
@Benoit'a answer has exact solution i am answering with additional knowledge: @ Benoit'a答案有确切的解决方案我正在回答其他知识:
1. one way as Benoit answered is add following inside application tag of AndroidManifest.xml
1. Benoit回答的一种方法是在
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 2.我们可以直接添加版本代码
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
4030500 is version code which is stored inside 4030500是存储在其中的版本代码
google-play-services_lib>res>values>version.xml 谷歌播放,services_lib>水库>值> 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
结论:最新的Google Play服务需要一个版本名称,可以在
AndroidManifest.xml
中使用<meta-data .. />
来提及
Note: I would strongly recommend to use 1st way 注意: 我强烈建议使用第一种方式
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.
如果您使用的是Google Play服务7.0或更新版本,Gradle会自动合并清单并为您提供所需的元数据。
(...) Google Play services 7.0 also has one other time saving feature if you're using Gradle: it automatically includes the
(...)如果您使用Gradle,Google Play服务7.0还有另一个节省时间的功能:它会自动包含
<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!
在您的AndroidManifest.xml中输入 - 无需手动添加! 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.
注意:这不适用于完整的播放服务或播放服务全套AAR - 只有粒度AAR内置了它。
Just make sure to add the below two meta-data tags to 'your' application's AndroidManifest.xml 只需确保将以下两个元数据标记添加到“您的”应用程序的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. 这个解决方案对我有用。
I imported my existing project from Eclipse to Android Studio, In Eclipse project Integers.xml
was containing hardcoded value as following 我将现有项目从Eclipse导入Android Studio,在Eclipse项目中,
Integers.xml
包含硬编码值,如下所示
<integer name="google_play_services_version">5089000</integer>
causing version conflict with latest version of Play Services being built by Android Studio. 导致版本与Android Studio构建的最新版Play服务冲突。 after removing this line from
Integers.xml
it started working for me. 从
Integers.xml
删除此行后,它开始为我工作。
I did create a file "version.xml" in the res/values folder of the included copy of google services and pasted the code: 我确实在所包含的google服务副本的res / values文件夹中创建了一个文件“version.xml”并粘贴了代码:
<?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 原始副本错过了文件,它确实解决了我的问题
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" />
Add <meta-data>
after closing <application>
tag. 关闭
<application>
标签后添加<meta-data>
。 This solved my problem 这解决了我的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.