I want to check out the new Awareness API which is quite new. I’m using Play Services 9.0.2. The documentation has this example:
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(Awareness.API)
.build();
client.connect();
However, there is no hint which dependency needs to been added. Any idea?
I found it out: I need to upgrade to PlayServices 9.2.0 and the dependency is hidden in play-services-contextmanager. Just add those dependencies and here we go:
compile 'com.google.android.gms:play-services-awareness:10.2.4'
Please use the latest play services library, at the time I updated this answer it was 10.2.4
If you want to know the latest Dependency you can use my web tool called DependencyLookup.
Keep in mind that this library was added in the Play Services Repository v31. Make sure that you have at least that version installed in the SDK manager.
You need to add the library of Google Play services to your project.
Set up Google Play services
To access the Awareness API, your app's development project must
include Google Play services. Download and install the Google Play
services component via the SDK Manager and add the library to your
project. For details, see the Android guide to setting up Google Play
services.
Source
Set up Google Play services
To access the Awareness API, your app's development project must include Google Play services. Download and install the Google Play services component via the SDK Manager and add the library to your project. For details, see the Android guide to setting up Google Play services.
which is apparently on the same page you got your code sample from here
Most of the times the number of method references in your app exceeds the 65K limit, your app may fail to compile. So in order to mitigate this problem when compiling your app ,specify only the specific Google Play services APIs your app uses, instead of all of them.
compile 'com.google.android.gms:play-services-basement:9.2.0'
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'
You will find the complete solution here:
http://xordroid.com/create-intelligent-apps-with-google-awareness-api/
Starting PlayServices v9.6.0, contextmanager has been changed to awareness
So, the previous answers won't be working.
The correct dependencies, as of v10.2.4 are
compile 'com.google.android.gms:play-services-basement:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'
Related
I used to use old version of Google Play Services in my projects. But now I keep getting warnings when I upload my apps to Google Play. These warnings says that I have to update my Google Play Services.
I have the latest version of Google Play Services in SDK manager with Rev.49
In the last versions of Google Play Services, I can find the Google Play library in the following directory:
SDK --> /extras/google/google_play_services/libproject/google-play-services_lib/
But now there is no libproject/google-play-services_lib/. Where can I get the library?
Check out this answer: https://stackoverflow.com/a/37311511/8294916
Or the answer directly below it: https://stackoverflow.com/a/37356709/8294916
Hopefully you can migrate over to Android Studio, but if you're stuck with Eclipse because you're working on a legacy project, I feel for you! :(
I am trying to include a SMS feature from Google play services support libraries to improve the authentication process. The documentation around it recommends using atleast minimum of 10.2 play services in order to use it.
Prerequisites:
The SMS Retriever API is available only on Android devices with Play services version 10.2 and newer.
However, when I go to build my project specifying the 10.2.0 version of in gradle, Android studio tells me it is unable to resolve this dependency from either jcenter or google's repos.
compile 'com.google.android.gms:play-services-auth-api-phone:10.2.0'
Error:org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.google.android.gms:play-services-auth-api-phone:10.2.0.
I tried searching for the package, but couldn't find that version: google's maven repos only show 11.0 and above.
It would be really helpful if someone could point me to the minimum available version of play services libraries over 10.2 that can be used to make this work.
Versions of Google Play services prior to 11.0.0 are only available through the SDK Manager. Make sure you have installed the Google Play services item in the SDK Tools tab of the SDK Manager.
However, in the case of the SmsReceiverClient API, that class was only added in Google Play services 11.0.0 SDK. It may be that the underlying implementation did exist back to 10.2, but was not public.
In any case, Google Play services releases an SDK only after it is made available to all users and will automatically update the vast majority (99.5%+) of users within the first week or two of availability. Given that 11.0.0 has been available for over 6 months, it should not be any issue in relying on the 11.0.0 library.
I'm using Android studio to develop a Google maps app. I'm trying to test it through a online emulator. My version of Google play services is 10.2.1, the emulator uses play services 10.0.84. There is no flexibility on there end. Is there a way to add or change my google play services to match the one they are using?I looked in dependencies under project structure, but I didn't see a way to add additional services. Any help would be greatly appreciated.
Simply change your Google Play dependencies to match whatever version you feel like. Example:
compile 'com.google.android.gms:play-services-games:10.2.1'//Replace 10.2.1 with 10.0.84 or whatever version you want
This is an example using play-services-games, but you can either use the full library or each individual dependency. It will work, as long as you change ALL the dependencies using play services to the same version
I have downloaded a demo project of GSM services.
For using it, I need to install a file name Google could messaging but, it is missing from my SDK.
How can I add this file to my SDK?
New To Android
If you use GCMS (Google Cloud Messaging Services), you need to build a library project which uses Play Services and import it into your work-space.
Generally:
Install the Android SDK from this link.
Download and configure the Google Play services SDK, which includes the Google Maps Android API. You can see the setting up on this link.
Don't forget to add the required Google Play services settings in your application's manifest.
When you add the Play Services library to your project, be sure to add it with resources, as described in Setup Google Play Services SDK. The key point is that you must reference the library. Simply adding .jar file to your project won't work. You must follow the directions for referencing a library, or your app won't be able to access the library's resources, and it won't run properly.
You can get the full instructions from Setting Up Google Play Services.
i am using google play services in my project, i am trying to use google map v2 service in my app.
For this i included play services as dependency in build.gradle file as mentioned in this thread.
for now the latest version of play services is 3.2.65 and i am pointing to it. Ok.
So my question is ,In the future when google releases newer version of play services and the device has play services version above 3.2.65 which was specified in build.gradle file, will cause any problem or not? And will my application adapts the latest feature of play services automatically or i have to release updates of my application every time google releases newer version of play services.
And if not then is there any other way or including play services in module dependency so that my application will always use updated version of play services.
Thanks
My guess is you have to recompile your project with a newer version of the library.
Various library versions are downloaded on your machine and used to compile the project.
SDK_DIRECTORY/extras/google/m2repository/com/google/android/gms
Of course Google releases things in order to preserve compatibility, so if you don't need any new feature/API you don't have to update your project.
In your build.gradle file, you can also write in this way:
compile 'com.google.android.gms:play-services:3.1.+'
So you will pick up any new 3.1.x version whatever is the latest number.
In the future when google releases newer version of play services and the device has play services version above 3.2.65 which was specified in build.gradle file, will cause any problem or not?
No, it won't cause any problems. Google Maps Android API v2 is developed in a forward-compatible way. No change will ever be made that can break older apps.
And will my application adapts the latest feature of play services automatically or i have to release updates of my application every time google releases newer version of play services.
Depends. Most of the bug fixes are made in the Google Play Services app and you don't need to update client library. Because client library has almost no code, there is low chance any bug will appear there.
If you want to use new features, you will obviously have to update the library to be able to call new APIs.