清单的应用程序标记中缺少名称为“com.google.android.gms.appstate.APP_ID”的元数据标记

Posted

技术标签:

【中文标题】清单的应用程序标记中缺少名称为“com.google.android.gms.appstate.APP_ID”的元数据标记【英文标题】:Missing metadata tag with the name "com.google.android.gms.appstate.APP_ID" in the application tag of your manifest 【发布时间】:2014-05-09 08:39:00 【问题描述】:

NUM_OF_TRIES_TO_FIX_THIS=12;//我在数apk的

所以我们遇到了一个大问题,距离发布我们的应用还有 2 步之遥,但我们无法在我们的应用中实现 google play 服务。 它一直在日志中告诉我们:

03-29 22:36:21.709: E/ValidateServiceOp(9477): Using Google Play games services requires a     metadata tag with the name "com.google.android.gms.games.APP_ID" in the application tag of your manifest
03-29 22:36:21.729: E/ValidateServiceOp(9477): Missing metadata tag with the name "com.google.android.gms.appstate.APP_ID" in the application tag of your manifest.
03-29 22:36:21.809: E/ValidateServiceOp(9477): Using Google Play games services requires a metadata tag with the name "com.google.android.gms.games.APP_ID" in the application tag of your manifest
03-29 22:36:21.969: E/AndroidRuntime(13931): FATAL EXCEPTION: main
03-29 22:36:21.969: E/AndroidRuntime(13931): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
03-29 22:36:21.969: E/AndroidRuntime(13931):    at com.google.android.gms.internal.eh$h.b(Unknown Source)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at com.google.android.gms.internal.eh$h.a(Unknown Source)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at com.google.android.gms.internal.eh$b.ec(Unknown Source)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at com.google.android.gms.internal.eh$a.handleMessage(Unknown Source)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at android.os.Looper.loop(Looper.java:137)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at android.app.ActivityThread.main(ActivityThread.java:4960)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at java.lang.reflect.Method.invokeNative(Native Method)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at java.lang.reflect.Method.invoke(Method.java:511)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
03-29 22:36:21.969: E/AndroidRuntime(13931):    at dalvik.system.NativeStart.main(Native Method)

但我们的清单中有 id!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.uraniumdevelopers.etchcubes"
    android:versionCode="6"
    android:versionName="0.4" >

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

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.gms.appstate.APP_ID"
            android:value="457870338644" />
        <meta-data
            android:name="com.google.android.gms.games.APP_ID"
            android:value="457870338644" />
        <activity
            android:name="com.uraniumdevelopers.etchcubes.MainActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

服务的初始化是这样的:

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(
            getBaseContext());
    builder.addApi(Games.API).addApi(Plus.API).addApi(AppStateManager.API)
            .addScope(Games.SCOPE_GAMES).addScope(Plus.SCOPE_PLUS_LOGIN)
            .addScope(AppStateManager.SCOPE_APP_STATE).setViewForPopups(rl);
    mClient = builder.build();

我们非常感谢您的帮助!

【问题讨论】:

【参考方案1】:

替换 4 -> \u0034 例如

<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\u003457870338644" />

访问 http://developer.android.com/guide/topics/manifest/meta-data-element.html

【讨论】:

【参考方案2】:

尝试在 strings.xml 中添加您的 app_id 并在清单文件中提及该 id。

有关更多信息,请查看此答案。重要的是答案中的cmets。 Fatal exception in playservices

【讨论】:

以上是关于清单的应用程序标记中缺少名称为“com.google.android.gms.appstate.APP_ID”的元数据标记的主要内容,如果未能解决你的问题,请参考以下文章

Android:权限缺少名称和标签

主题更改时缺少操作栏

清单文件中缺少 Cordova 相机权限

将意图类型添加到 android Flutter 清单会导致主屏幕中缺少应用程序图标

使用资产前缀时,由于缺少清单文件,Capistrano部署失败

Django ValueError:缺少静态文件清单条目,但清单似乎显示了该条目