I am trying to implement a autocomplete places search following this article.
http://www.truiton.com/2015/04/android-places-api-autocomplete-getplacebyid/
I have followed all steps, and also added proper dependencies in my build.gradle file.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Also here are the meta data section in my 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"
android:value="#string/google_maps_key" />
also I have all the required SDK components installed. Still my android studio can not resolve the places part in the following imports:
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.AutocompletePrediction;
import com.google.android.gms.location.places.AutocompletePredictionBuffer;
import com.google.android.gms.location.places.Places;
this is how they look as they can not find the Places part.
How can I resolve this issue? I am using SDK 19 for my app.
Add compile 'com.google.android.gms:play-services-places:<version>, where <version> is perhaps at least: 9.2.1 under dependencies in your modules's build.gradle
In play-services 9.2.0 the places API is no longer located in location. Those are now in their own places dependency. To resolve those you should add this to your build.gradle.
compile 'com.google.android.gms:play-services-places:9.2.0'
check out
Places class is removed from android play services 9.2.0
The Places API was only added in Google Play services 7.0: you'll need to update your dependency to be at least 7.0.0, although the latest as of this answer is 15.0.0.
Note in almost every case, you should use selective APIs to only include the portions of Google Play services you need. In that case, you'd actually use a dependency such as
implementation 'com.google.android.gms:play-services-location:15.0.0'
Since Play Services version 9.2 we should add the following dependancy to access Google Places API.
compile 'com.google.android.gms:play-services-places:11.0.2'
The latest version at the time of this writing.
The accepted answer for this thread was outdated.
Add following two dependencies in your build.gradle(Module: app)
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
try including
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
Just add it in your dependency (build.gradle [Module:Application])
Then file -> Invalidate caches/restart-> invalidate and Restart
For latest versions of google play services for location changes have been made. Check [Selective Google Play Services API not finding classes
I was also faced with the same issue recently and adding this
implementation 'com.google.android.gms:play-services-places:11.4.0'
to my dependency under build.gradle(app) file solves the problem for me.
NB: make sure the version of your dependencies are all thesame if not you will encounter or errors
Related
From what I understand, in order to use firebase messaging I need my google-play-services version to match my firebase-messaging version in my app's build.gradle. According to Google's Firebase setup guide the firebase version I should use is 17.3.0, so I figure I'm supposed to use google-play-services version 17.3.0, but that doesn't work because Android Studio can't find that version:
Here is how I've added them to app/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.android.gms:play-services:17.3.0'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation "com.android.support:support-v4:24.1.1+"
// SUB-PROJECT DEPENDENCIES END
}
What am I doing wrong here?
From what I understand, in order to use firebase messaging I need my
google-play-services version to match my firebase-messaging version
That is no longer true, google recently changed to semantic versioning so libraries are no longer tied to the same version. 12.0.1 I believe was the last version that you could make the same version for everything play services related and everything else must follow the new versioning system
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
You can check googles maven repository for the latest version of any library
https://dl.google.com/dl/android/maven2/index.html
Also you should not include all of google play services in your project and you should only declare the libraries you need as this makes your app smaller.
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
I am trying to implement a autocomplete places search following this article.
http://www.truiton.com/2015/04/android-places-api-autocomplete-getplacebyid/
I have followed all steps, and also added proper dependencies in my build.gradle file.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Also here are the meta data section in my 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"
android:value="#string/google_maps_key" />
also I have all the required SDK components installed. Still my android studio can not resolve the places part in the following imports:
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.AutocompletePrediction;
import com.google.android.gms.location.places.AutocompletePredictionBuffer;
import com.google.android.gms.location.places.Places;
this is how they look as they can not find the Places part.
How can I resolve this issue? I am using SDK 19 for my app.
Add compile 'com.google.android.gms:play-services-places:<version>, where <version> is perhaps at least: 9.2.1 under dependencies in your modules's build.gradle
In play-services 9.2.0 the places API is no longer located in location. Those are now in their own places dependency. To resolve those you should add this to your build.gradle.
compile 'com.google.android.gms:play-services-places:9.2.0'
check out
Places class is removed from android play services 9.2.0
The Places API was only added in Google Play services 7.0: you'll need to update your dependency to be at least 7.0.0, although the latest as of this answer is 15.0.0.
Note in almost every case, you should use selective APIs to only include the portions of Google Play services you need. In that case, you'd actually use a dependency such as
implementation 'com.google.android.gms:play-services-location:15.0.0'
Since Play Services version 9.2 we should add the following dependancy to access Google Places API.
compile 'com.google.android.gms:play-services-places:11.0.2'
The latest version at the time of this writing.
The accepted answer for this thread was outdated.
Add following two dependencies in your build.gradle(Module: app)
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
try including
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
Just add it in your dependency (build.gradle [Module:Application])
Then file -> Invalidate caches/restart-> invalidate and Restart
For latest versions of google play services for location changes have been made. Check [Selective Google Play Services API not finding classes
I was also faced with the same issue recently and adding this
implementation 'com.google.android.gms:play-services-places:11.4.0'
to my dependency under build.gradle(app) file solves the problem for me.
NB: make sure the version of your dependencies are all thesame if not you will encounter or errors