Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google map api v2, and older version of google play services lib

I am going to use maps in my android application and I should use google play services. I read lots of q\a here like this. In the mentioned question, the accepted answers suggets using older version of google play services lib, like the one for Froyo. I downloaded google play services r10 and used it in my app, but I got errors.

If I exclude this line of code from manifest:

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

and run the app in my device (current version of google playe services in my device is 3.2.66 ), it throws error:

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" />

and if I include it with android:value=4030500 the app runs but says that I should update my "google play services".

So what should I put android:value or Is my way correct at all ?

Regards

like image 358
Babak Fakhriloo Avatar asked Nov 16 '13 13:11

Babak Fakhriloo


3 Answers

I downloaded google play services r10 and used it in my app

The above statement is the root cause of your problems. If you really used r10 (or even r12), than after removing

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

from your AndroidManifest, you would not get this error:

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" />

This error simply says, you are linked to 4.0.30 version of the Google Play services library.

So the solution is to remove the above meta-data and making sure you link to one of the previous versions.

If using gradle or maven, just set your dependency version to 3.2.65. If developing the old way, download Google Play services for Froyo in Android SDK Manager, copy that from sdk/extras/google/ into your working directory and in your project preferences choose this project as a library dependency project.

like image 110
MaciejGórski Avatar answered Sep 22 '22 18:09

MaciejGórski


I was also facing the same problem. After adding these two lines in my manifest file It worked .

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

<meta-data android:name="com.google.android.maps.v2.API_KEY"
          android:value="AIzaSyBAjfcxZvbt_COHjy7igHZnLBfsO1cfoM8" />
like image 29
Zohra Khan Avatar answered Sep 19 '22 18:09

Zohra Khan


Update your google play services to the latest from your sdk manager which is rev 13

You need to add the below to manifest file

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

https://developers.google.com/maps/documentation/android/start#add_the_google_play_services_version_to_your_apps_manifest.

It's a new requirement added from the last revision 13 update to google-play-services.

like image 21
Raghunandan Avatar answered Sep 21 '22 18:09

Raghunandan