The meta-data tag in your app's AndroidManifes

2019-08-02 05:56发布

问题:

I'm trying to implement google-play-services library and it seems to me I'm doing everything right.

Here's my stacktrace:

06-14 13:17:51.804: E/AndroidRuntime(22809): java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 8298000 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" />
06-14 13:17:51.804: E/AndroidRuntime(22809):    at com.google.android.gms.common.GooglePlayServicesUtil.zzak(Unknown Source)
06-14 13:17:51.804: E/AndroidRuntime(22809):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
06-14 13:17:51.804: E/AndroidRuntime(22809):    at com.google.android.gms.maps.internal.zzy.zzaQ(Unknown Source)

Here's my Manifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1alpha"
    package="ru.vezdeok.driverapp">

   <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="23" />

    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


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

    <application
        android:name=".app.App"
        android:allowBackup="true"
        android:icon="@mipmap/icon"
        android:theme="@style/AppTheme"
        android:label="@string/app_name">
... A bunch of Activity declarations
    <meta-data
         android:name="com.google.android.maps.v2.API_KEY"
         android:value="@string/google_api_key">
         <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        </meta-data>

    </application>

</manifest>

now, google-play-services_lib is attached and integer/google_play_services_version reads fine and it is 8298000 as it needed. But even if I hardcode android:value="8298000" I still got an error

I also tried to remove <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> as I read on stackoverflow that it's not necessary but that didn't help me also.

So.. what's wrong? It seems that I declared meta-data exactly how I should

回答1:

Your meta-data is nested and I think that's not the way it's supposed to be. Try to move the inner meta-data out of its current position:

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


回答2:

Just as an aside, if you find yourself here after switching between multiple branches, make sure you manually uninstall the app on your test device and do a clean within Android Studio.