Im trying to add google play API to my android game and i followed the instructions in their site.
I got this error in the emulator run, trying to solve it. (on my phone
I have found the solution which worked for me. Assuming that your are using the Google Maps V2 API you need to get the API Key from [https://code.google.com/apis/console/][1]
Make sure you have the following in Android Manifest.xml:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA7xyeYSyonpXb6cqrmrBOCmKGd8q6FOlI" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Didn't specify what IDE you use?
- In case of gradle / Android studio you can check and configure in build.gradle
file, setting 1, as described here, other settings are not necessary and can be removed.
- In case of other IDE / Eclipse check project references and correlate jar file from lib folder with @integer/google_play_services_version
value from sdk project.
Check the following settings:
in build.gradle
dependencies {
compile 'com.google.android.gms:play-services-base:7.5.0@aar'
in AndroidManifest.xml
, usually should add in your project manifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
in res/values/version.xml
from referenced sdk project or included in your own project manifest file
<resources>
<integer name="google_play_services_version">7571000</integer>
</resources>
To find out what version can be used in build.gradle
or to download specific version of google play services sdk
, check here and here.
Add the below script in dependencies.gradle
, it will download the latest play service lib automatically, and you can find them on local path such as: m2repository/com/google/android/gms/play-services
.
dependencies {
compile 'com.google.android.gms:play-services:4.2.+'
}
Google Play services needs to be listed as a dependency in the code (which you have done) and also on the device/ emulator that you are using.
When creating the virtual device, go to *AVD --> Create virtual device --> new hardware profile --> next --> select the image as per requirement. You should have an option of seeing the google play services version. If that isnt high enough then you probably dont have the images needed which can be downloaded from android SDK
EDIT : Sorry i meant to type AVD and not ADB. Android Virtual Device Manager is a mobile icon with some green circles below it located on top right corner. This is used to launch new emulators with select hardware settings. These settings are downloaded from the android SDK in form of system images under the different APIs
In my case I'm working with wearables and I must use the Google Play Services wearable library:
compile 'com.google.android.gms:play-services-wearable:7.5.0'
I was getting the message Google Play services out of date. Requires 7571000 but found 7327534
in the log.
And the watch suggested updating Android Wear and automatically run it on the phone. But Android Wear couldn't be updated since there were no more updates available, so in the end I changed the library version from 7.5.0
to 7.3.0
and it worked.