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

androidgoogle mapsgoogle-play

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

Best Answer

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.

Related Topic