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 :)
Related
I have a working Android app using:
Google Maps (play-services-maps)
Google Location, Activity Recognition, and Places (play-services-location)
Google Analytics (play-services-analytics)
Google Mobile Ads (play-services-ads)
I'm currently using version 8.3.0, everything works fine. I'd like to upgrade to the last version, 9.2.0. When I change the number in the gradle files, Android Studio is unable to find the APIs packages & classes (saying "package XXX does not exist" and "Cannot find symbol class YYY").
I currently have no google-services.json file, do I need it now? I tried without success, probably because I have several modules / submodules, and I don't know where the json file is needed or not.
The problem is that I need a package name to create the JSON file, and I have some library modules, without package name, using Google APIs.
If needed, here is the project structure:
Maybe you did something wrong while upgrading your project. Make sure you follow the correct steps in upgrading. I suggest you to retry the process of upgrading, but make sure you do the correct way. Like in configuring your build and setting up Google play service.
For your question about google-services.json, Google-services.json contains developer credentials and configuration settings, which is needed to verify while connecting with GoogleApiClient. Though your service is working fine without it. But it will only work with your test device, as it is detecting your developer account. And after you releae your app in public, it will not work without the json file. So you need it and don't delete.
sources: What does google-services.json really do?
So, I finally got it: I was using the AutocompletePrediction.getDescription() method, which has simply been removed (and replaced by AutocompletePrediction.getDescription .getFullText()). That call made gradle stops building -_- .
Thanks Google for removing stuff without deprecating it for a while (though the docs says that the method is deprecated: https://developers.google.com/places/android-api/releases)...
I can also confirm that in my case, the google-service.json file is NOT required.
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.
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.
I've set the Google play services API on my android app project, I did as I saw in the documentation for google android developer. I started by copying the google library services in the folder of my project, then I added the refernce in the build (like we see in the photo the gooogle play services lib is perfectly deployed) and then I tried to copy this piece of code in android but manifiest not recognize the second line. android:value="#integer/google_play_services_version"
So any help for that please ! Thanks
Xavier is right, there are no resources in the GooglePlayServices JAR file you usually get your compiled classes.
As you're in Android Studio you can just add to your gradle dependencies : compile 'com.google.android.gms:play-services:5.2.08'
I am on Android Studio and I have followed the instructions on Google here.
I have downloaded via the SDK Manager the google repository, google play services for froyo and not for froyo.
My gradle
// this works
// compile 'com.google.android.gms:play-services:4.1.32'
// this doesn't
// compile 'com.google.android.gms:play-services:3.2.65'
(I uncomment one or the other, not both at the same time)
My manifest
<application
...
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
Any idea ?
iirc, Google doesn't actually provide an aar for froyo play services. I think you have to manually import ANDROID_SDK\extras\google\google_play_services_froyo\libproject\google-play-services_lib from your SDK directory as a module, then compile that module as a dependency in gradle.
The link you referenced that you were following mentions nothing about froyo or gradle, are you sure you're following the right tutorial? This seems to indicate my answer above if correct: http://developer.android.com/google/play-services/setup.html
The workaround is from Nov 2013 to hardcode the gms version in the manifest
https://code.google.com/p/android/issues/detail?id=61675
"com.google.android.gms.ads.AdActivity" does not exist in version 3.2.65 (Froyo) of Google Play Services. Google seems to have stopped updating the library for google_play_services_froyo.
a
you will need to use google_play_services (current version is 4.3.23) to use AdView and AdRequest, but that version requires a minsdk of 9 (Gingerbread).
I am facing the same problem as you, and I have a small percentage of active users still using Froyo (mostly in third world countries). For now I intend to split my apps to different flavors- one of which will use the Admob standalone SDK until they stop serving ads (and it'll remain ad free for my Froyo users).