Question

I have been working for 2 days in this issue .The problem is that whenever I try to run my application I am getting this exception:

Caused by: java.lang.IllegalStateException: The meta-data tag in your app's

AndroidManifest.xml does not have the right value. Expected 5077000 but found 0. You must have the following declaration within the element:

So I have added theese line as a secondry meta tag

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

But this time another message says this applicaiton wont run without google play services which are missing your phone. But I have added Google Play services as a library

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.androidmapsdemo.MainActivity" >




    <fragment 
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
         android:layout_width="match_parent"
          android:layout_height="match_parent"



        />

</RelativeLayout>

this is my manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.androidmapsdemo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />
<permission 
    android:name="com.example.androidmapsdemo.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-feature 
    android:glEsVersion="0x00020000"
    android:required="true"/>
<uses-permission  android:name="com.example.androidmapsdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"  />

    <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.maps.v2.API_KEY"
            android:value="XXXXXXXXXXXXXXXXXXXXXXXX"/>
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
Was it helpful?

Solution

Before doing anything with the map, you need to check the device has google play services installed on the device.

For example, putting this in your onResume().

    // Getting status
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

    // Showing status
    if(status==ConnectionResult.SUCCESS)
        tvStatus.setText("Google Play Services are available");
    else{
        tvStatus.setText("Google Play Services are not available");
        int requestCode = 10;
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
        dialog.show();
    }

That's just an example!

Have a look online for better solutions on checking whether a device has Google play services installed. You can even prompt the user to download and install them to resume using your app.

OTHER TIPS

Just because you added the google play services library to your app does not mean it will work.

Your device also needs to have google play services installed on it and if your device does not then that means you will not be able to use the app on that device.

The only devices that have google play services are ones that are google authorized and have access to the google play store.

You should be checking if the device actually has google play services installed before you do anything so that it does not just crash for the user

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top