In my app I have added Google Maps and they work fine. I want to add a PlaceAutocompleteFragment. I am using the key which I had already generate for maps and I have enable the option Places Api from google.console. I have added these to my build.gradle:
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
but when I try to use PlacesAutoCompleteFragment then Android Studio can't resolve this.
The problem here is that PlaceAutocompleteFragment didn't exist in version 8.3 of Google Play Services.
This isn't documented very well, but you can see on this blog that PlaceAutocompleteFragment was "announced" in December 2015.
You can also see in the PlaceCompleteFragment Google code samples on GitHub that they are using version 8.4 of GooglePlayServices.
I also had this problem, and updating Google Play Services is what made it work.
So, update Google Play Services in the SDK Manager, and then modify the build.gradle like so, and it should work:
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
Update
In newer versions of Google Play Services, they have broken out the Google Places API, so you need to include it in addition to Maps and Location:
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile 'com.google.android.gms:play-services-places:11.0.2'
Related
My Android app has been successfully using maps by including the following in my gradle ...
compile project(':googleplayservices_lib')
My SDK manager says I have rev 32 which appears to be the latest. So with this, everything has been working just fine.
Now I'm enhancing the app and I saw some posts that says I can now use zIndex parameter when adding a marker to control the Z Index. But to do this I must add the following to my gradle . . .
compile 'com.google.android.gms:play-services-maps:9.2.0'
So now my gradle file has this dependencies section . . .
dependencies {
compile project(':library')
compile project(':googleplayservices_lib')
compile files('libs/gson-2.2.4.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:design:22.2.1'
compile 'com.google.android.gms:play-services-maps:9.2.0'
}
Now I'm able to set zIndex but this new version apparently comes with breaking changes. For instance the following no longer works . . .
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
map is a GoogleMap. The compiler cannot resolve the getMap() method. My problem is that I can't seem to locate the documentation on this new maps revision where it discusses breaking changes for this new version. Does anyone know where I can find such information?
My Android app has been successfully using maps by including the following in my gradle
Presumably, that is an in-project copy of the old Eclipse library project edition of the Play Services SDK. Ideally, you would have moved off of that to the Play Services SDK artifacts back when you moved to Android Studio.
My SDK manager says I have rev 32 which appears to be the latest
Since you are using a local in-project copy, what the SDK Manager reports is not directly relevant.
Also, Google has not been maintaining that library project for at least the past several months, so "latest" of that library is meaningless with respect to using the latest version of the Play Services SDK.
So now my gradle file has this dependencies section . . .
I am surprised that compiles. Remove compile project(':googleplayservices_lib'). If you are using parts of the Play Services SDK beyond Maps V2, use appropriate and compatible artifacts for those APIs as well.
The compiler cannot resolve the getMap() method.
getMap() was deprecated about 20 months ago, in favor of getMapAsync().
My problem is that I can't seem to locate the documentation on this new maps revision where it discusses breaking changes for this new version.
Maps V2 release notes are in the Play Services documentation. A subset of Maps V2 release notes are incorporated in the overall Play Services release notes.
I'm trying to use the new Awareness API in an app but the only way that I can include it in my code is by using
compile 'com.google.android.gms:play-services:9.2.0'
in my gradle file.
I tried using
compile 'com.google.android.gms:play-services-awareness:9.2.0'
but it doesn't seem to exist.
Does anyone know what the correct compile path for selective compile of the awareness API is?
Thanks in advance.
It actually does exist.
//Awareness API
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'
Today you have to include:
compile 'com.google.android.gms:play-services-awareness:10.2.4'
If you want to know the latest Dependency you can use my web tool called DependencyLookup.
I currently have the following line in my dependency:
compile 'com.google.android.gms:play-services:4.2.42'
I put this in longn back when I was just starting out to code my app and now I realize that this is what is probably causing my app to bloat at about 20 MB
Is there a way to identify and specifically import only necessary services to reduce my app size? I am pretty sure there are ways to import only specific modules, but also pointers on how I can identify which modules I need will be appreciated
From version 6.5, you can instead selectively compile Google Play service APIs into your app,
For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
please check this link
First, you need to check your project & identify which Play Services Modules are used. Then, You can selectively add the play services APIs which are necessary to your project.
For Ex : The below will be add Google Analytics and Maps modules to your app.
dependencies {
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
}
You can use something like this
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
I am using google play services API, and from old version of code, i included the whole library. Now i want to use Selectively compiling APIs from this link https://developers.google.com/android/guides/setup. But i can't find what does com.google.android.gms.appstate.AppStateManager come from .
I already have this
compile 'com.google.android.gms:play-services-base:7.5.0'
compile 'com.google.android.gms:play-services-identity:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-games:7.5.0'
compile 'com.google.android.gms:play-services-plus:7.5.0'
but none of them have.
Please help.
The AppStateManager of the Google Play Services is DEPRECATED, so they have hidden the AppState play-services-dependency.
At the moment you can still get it via the following dependency, but it will probably get deleted soon.
compile 'com.google.android.gms:play-services-appstate:7.8.0'
or for Updated version use
implementation 'com.google.android.gms:play-services-appstate:8.4.0'
Add the following dependency in build.gradle rember this is for old DEPRECATED
compile 'com.google.android.gms:play-services-appstate:9.0.0'
This is work for me
Is there a way to add google game services in a simple way using gradle 0.5+ like how its possible with the support library or the google play services:
dependencies {
compile "com.android.support:support-v4:13.0.0"
compile 'com.google.android.gms:play-services:3.1.36'
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
}
Play Game Services is not a separate library from the Google Play Services library. It seems that you are using a very old version of play-services through. Try the newest version, which definitely has the Games API:
compile 'com.google.android.gms:play-services:6.5.87'