1. Need To create a new AVD WITHOUT GoogleApis, for example, the next picture shows my emulator for testing.
- The Google Services platform is the component of the OS, which provides of those new features, so the most important thing to remember is to ALWAYS INSTALL the latest version of this file, in my case I downloaded the following file com.google.android.gms-19032013.apk. Be careful to check the LATEST version, at the time of writing this post, this file was the latest one.
- I read many in many posts to download and install the following file "com.android.vending-1.apk", but those posts do not mention that this file is simply the Google Playstore APK, neither mention that need the LATEST version, so I downloaded as many files as you can imagine, trying to make the API work. Thus, the file we need is again the LATEST apk file of the Google Playstore, in my case I downloaded the "Playstore v4.0.27.apk" file.
If you encounter with the (491 error) when trying to update the Google Play Services, or if you are installing some APK right to the /data/system/, maybe you searched for a solution a lot but I certainly can tell you that the answer is not in that way.
I will omit the steps about how to create and configure the API key for android applications, (but if you are interested, I've added some reference links for this) instead I will focus on the project configuration using the (not my favourite IDE) Eclipse; when the Android Studio gets stable, I will post a new entry (if necessary) about how to configure a project in that IDE.
Ok, let get back to what we want.
1. Create a project.
2. After you created the project, need to import the existing "google_play_services-lib" eclipse project, into the new project, by doing the following:
3. IF is the first tie you are attempting to use the API, then need to import the Google Play Services Lib into the workspace.
File > Import...
Then go to the android-sdk installation path and browse to: /SDK_HOME/extras/google/google_play_services/libproject/google-play-services_lib.
I read in many posts, that is NECESSARY to copy the project into the current workspace, this due to bugs in Eclipse IDE.
4. After this has been done download the source code and replace in your new project (the source code is at the end of the post), you'll notice that many classes couldn't be found.
Indeed, you need to add the new imported project which is marked as a Library into the Android settings of the project.
Right Click on Project > Properties > Android
5. One last thing to not forget is that Eclipse external libraries need to be copied into the "LIBS" folder of the project to make them available to the Build.
Then copy the "google-play-services.jar" file located in the "LIBS" directory of the "google-play-services_lib" imported project.
Also do not forget to add it to the compilation build path of the project, this for making those classes available for IDE.
6. OK, now configure the AndroidManifest.xml, and use the Google API key generated for your account.
7. Finally a very important step is to add the google-services.jar file into the APK, this to avoid exceptions like the following.
So do the next steps:
Right clik project > Properties > Java Build Path.
Go to "Order and Export" tab.
8. Run thh project.
The application works perfectly!!!
About my search on web.
Google Play Store, A.K.A (com.android.vending.apk)
Google Play Services, A.K.A. (com.google.android.gms.apk)
step by step guide
NOTE, don't forget that you can use your OWN keystore to generate the KEY, but need to configure the Default debug store @Eclipse, Window> Preferences > Android > Build.