How to do a rollback from google-play-services in eclipse? - android

I have problems with google play services 6.5.87 and I need to rollback/install version 6.1 ( 6.1.71 or 6.1.11). How do I do that? Where can I get the files? In thh Android SDK I can't see any option for that. I use Eclipse.
I found a file version.xml in google-play-services_lib project
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">6587000</integer>
</resources>

You cannot roll back by just changing the integer, you need to specify the build you are actually using.
If you are building the google play services project, you would use this line in your manifest so that the build number is generated dynamically.
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
That being said, you still need to make sure the version you are building is an version older than the one you are having problems with.
Here is a good article on how to build using a project:
http://hmkcode.com/adding-google-play-services-library-to-your-android-app/
However, if you are copying a previously built library, then you must reference the correct library in the properties of your project. Please check your settings for Eclipse / Android Studio to make sure you have added the older library. You should still use the dynamic value for the integer in your manifest, but if you insist on using a static value, you can find the integer value of the library in google-play-services_lib/res/values/version.xml

The easiest way to do this is probably to download the latest "Google Repository" via the SDK Manager. Add ${android_sdk}/extras/google/m2repository/ to your list of repositories to pull dependencies from (See "Declaring Repositories" in this). Then put your old version number back in your maven dependency declaration. (This would be if you pulled the Google Play services dependency via Maven/Ant declarations.)
You could also obviously copy the aar file out of the m2repository directory, but then you have to manually manage the dependencies and deal with class not found exceptions.

Related

Google play services after importing to AS from Eclipse

I just imported a project from Eclipse to AS. In the project I'm using Google Maps, and in Eclipse I had these lines in the manifest:
<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">
Importing the project left these lines. Do I still need them in the manifest now when using Gradle or can I just add this line to gradle.build and thats it?
compile 'com.google.android.gms:play-services:9.4.0'
Short answer- you need both!
Explanation (if you require it)
The Gradle lines basically tell Gradle to pull in the library called 'com.google.android.gms:play-services' and the version '9.4.0'. This is just a bunch of code you'll want to include in your project. (It's a lot of code, when your project looks bigger you'll want to split that out into just the components you use)
Meta data is used for different things than Gradle dependencies are- specifically in your case, you are using it here to:
supply your google api key, and,
supply your google play services version number
NOTE: hide your API key!!!! (just google "why should I hide my api key")
The version number is the version that your app expects to use, which you might specify if you are working on an older version, or for a workaround. Typically, these fields are just used to show maps.
The API key is used to access your Web Console app client for your app- i.e., the app on Google API Console that you linked to your Android Studio app. This is not something you want publically exposed on Stack Overflow.
Hope that helps :)

Why do we need to copy the Google Play Services library in our project?

Why does Google have this note? [ref]
What is the harm in adding reference to the library in the SDK directory? I have done it and my app worked just fine.
I think maybe it could will change name in some sdk updates, so if you referece to your copy nothing can go wrong.
instead reference it on gradle to avoid this problem (Gradle work for us to avoid dependecy problem :)).
Yes, you can use it directly from there. I used to do it too till i realized what the problem could be.
If you are making no changes to the library it should work fine. But if you plan to add some build files or configuration etc you should copy it to the project. (I had some for my ant builds) If you dont have any, at the time of updating the library from SDK manager you lose everything you changed or configured. Apparently it deletes all unidentified or manually added stuff when updating the library.
With Android studio it is much simpler and you just add a dependency with required version to your build.gradle file.

Can I remove com.google.android.gms.version from AndroidManifest when I use gradle?

I wonder if I can remove this line safely:
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
from my AndroidManifest.xml when I use gradle to build my APK.
According to the website https://developers.google.com/android/guides/setup only when I choose "ECLIPSE WITH ADT" I have to add this line. For "ANDROID STUDIO" usage this is not mentioned.
But in my case I use Eclipse (with ADT) as IDE but I build with gradle. (Actually it is a libGDX project). So I added the play-services by using gradle:
compile "com.google.android.gms:play-services:8.1.0"
So I run the app on a test device and I tested to login with play-services and it worked fine without having the line above in my AndroidManifest.xml
But, maybe the login just does not need the "com.google.android.gms.version" value and another part of the play services lib needs it? But I cannot test all the possible ways to use the lib.
Does anybody know for sure?
Or for those of you who use Android Studio + play services: Does your AndroidManifest.xml have the line above?
Yes, as of Google Play services 7.0 (improved in 7.5 to remove the restriction on applying to the full play-services dependency), the <meta-data> tag is automatically added to your Manifest file by Gradle via Manifest merging.

Android error: Google play service version

I've this popular problem developing an android application with Eclipse:
error: Error: No resource found that matches the given name (at 'value' with value '#integer/
google_play_services_version').
So I've tried to import the google play library as specified here but I've this error:
Invalid project description.
C:\Users\Max\workspaceAndroid\google-play-services_lib overlaps the location of another project: 'google-play-services_lib'
Infact if I try to manage the libraries of the project I get this:
It seems that the google play libraries are already imported and I can't add new library.
The last chance I think I've is to add manually the string
compile 'com.google.android.gms:play-services:4.4.2#aar'
to my build.grade as specified in this answer but I don't know where find the file or if this will solve my problem.
How can I fix the error? Thanks!
Have you had the Google Play services installed already via the Google SDK Manager?
It looks like the following for me:
Here's what i did in the whole setup, to use the Google Maps Android V2 api
Google Maps API setup, Android V2 API
I had the same issue and was able to solve it by
Importing the google play services as an android project in eclipse
Adding reference to this imported project as a 'Lib' in
README.txt under google-play-services-lib reads like this;
Library Project including Google Play services client jar.
This can be used by an Android project to use the API's provided
by Google Play services.
There is technically no source, but the src folder is necessary to ensure that the build system works. >The content is actually located in the libs/ directory.
USAGE:
Make sure you import this Android library project into your IDE and set this project as a dependency.
Note that if you use proguard, you will want to include the options from proguard.txt in your configuration.

How To Find Android Google Play Services Version

I'm working on an android project which requires the use of google maps. I've been reading tutorials, and I have to add this to the AndroidManifest.xml file:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
The thing is, I don't know what number to substitute the "#integer/google_play_services_version" with.
If anyone knows what I should enter there, and how to obtain that integer value, I'd appreciate it.
There is no need to subsitute. The value #integer/google_play_services_version takes care of it. Just make sure you have the latest Google Play Services library which is updated.
You can find it under google-play-services_lib>res>values>version.xml if you wish to add the number rather than #integer/google_play_services_version.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">4030500</integer>
</resources>
Here is the official guide for setting up Google Play Services in your project.
FYI, you could find the version number in this folder:
~\android-studio\sdk\extras\google\m2repository\com\google\android\gms\play-services
Enjoy.
Error you have mentioned is maybe because of not adding Google play services lib as library of your project do the following.
Select File -> Import -> Android -> Existing Android Code Into Workspace and click Next.
Select Browse, enter
/extras/google/google_play_services/libproject/google-play-services_lib, and click Open.
3.Select Copy projects into workspace and click Finish.
Mark Google Play services as a library: Right-click the google-play-services_lib project, and choose Properties > Android. Tick the Is Library option.
Right click on your project -> go to properties -> click android -> click add button -> click google_play_services_lib -> ok -> apply -> ok clean your project
this will remove your error
If you are using gradle just make sure you have the updated google play services version (downloaded using SDK manager) and put this in your project module dependency section:
compile 'com.google.android.gms:play-services:+'
IMPORTANT NOTE: In general it is not a good practice to remove the concrete version of the source you are compiling against.
I was in a case where I had to use the Froyo version of the Google Play Services, and that version doesn't require the tag. In fact, the XML entry google_play_services_version does not exist in the Froyo+ version of the Google Play Services library

Categories

Resources