I want to just import into my project the dependencies from GoogleApi to use location to get longitude and latitude.
I was trying to follow this tutorial which they recommend to use the FusedLocationProviderApi, but they use eclipse, so I'm using android studio and I just want to add the dependencies for that library.
I know that if I include compile 'com.google.android.gms:play-services:7.5.0' in my build.gradle it will include all services I only need those for locating long and latitude, I don't want to use compile 'com.google.android.gms:play-services:7.5.0' because I want to keep my methods count low.
UPDATE:
When trying to include:
compile 'com.google.android.gms:play-services-location:8.0.0'
compile 'com.google.android.gms:play-services-maps:8.0.0'
I get
UPDATE 2
Got it working with: compile 'com.google.android.gms:play-services-location:8.1.0'
Use play-services-location instead of play-services.
Note, though, that for inexplicable reasons, play-services-location depends upon play-services-maps, at least for version 8.1.0. So, you will be pulling in the Maps V2 code as well.
Related
Android Studio and Google Maps dependencies have finally defeated me. I did have it working but had to change some things to get my app to use the correct API Key.
Now I click on run and it say's build successful, but it doesn't actually run the project on the simulator and it puts a whole load of red circles with white exclamation marks in the messages window. Nothing happens if you click on those circles and there's no explanation as to what they mean.
I've a feeling it's saying there are dependencies of the dependencies I've included but I've moved away from individual Play service includes and included the whole lot, with the whole support library and still nothing happens.
Can anyone tell me what's going on, or how I can fix this, or even where I look next to find out why this won't run.
These are my dependencies in my build.gradle.
dependencies {
compile files('libs/jackson-annotations-2.9.0.jar')
compile files('libs/jackson-databind-2.9.0.jar')
compile files('libs/jackson-core-2.9.0.jar')
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.android.support:appcompat-v7:25.2.0'
}
apply plugin: 'com.google.gms.google-services'
This is the error
This is where it says the build was successful
Thanks
Change compile 'com.google.android.gms:play-services:11.0.4' to compile 'com.google.android.gms:play-services-maps:11.8.0' // you dont need use all play-services
And try again!
I think that you have a dependency conflict, i suggest in this case to use the version 11.0.2:
compile 'com.google.android.gms:play-services:11.0.2'
btw, loading all the Play Services Library is not necessary to use Google Maps,
use only this dependency:
compile 'com.google.android.gms:play-services-maps:11.0.2'
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 trying to add google play service to my project but it gives me error when I try to edit build (Gradle).
How can I fix it?
In your configuration there some issues.
You are using the wrong build.gradle file.
It is your top-level file.
You should add this line in your app/build.gradle
There is a typo. You are missing the ' at the end of the line compile.
Use an updated version.
For example use:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:8.1.0'
}
Finally refer this official doc for more info.
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
For example if you need to make only your app aware of location updates add
compile 'com.google.android.gms:play-services-location:8.1.0' only in gradle or if you need only map choose compile 'com.google.android.gms:play-services-maps:8.1.0'.
Please replace
compile 'com.google.android.gms:play-services:3.1.36
with
compile 'com.google.android.gms:play-services:3.1.36'
One thing you can try is Right Click on app open module settings on Dependencies Tab click '+' icon and add there 'com.google.android.gms:play-services:8.1.0' and click search icon and add that dependency,
So i don't want to elaborate what you had done wrong as my colleagues figured it out.I like to say, while playing with Google Play Service
Selectively compile APIs into your executable
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
For example if you need to make only your app aware of location
updates add compile
'com.google.android.gms:play-services-location:8.1.0' only in gradle
or if you need only map choose compile
'com.google.android.gms:play-services-maps:8.1.0'.
Thank you.
Visit for more.
I'm trying to add a Leader Board to a Chrome cast project and am getting errors. Android project in Android Studio. In my gradle build - Error: more than one library with package name 'com.google.android.gms'
I understand why you don't want to use two different libraries with the same name, but not sure how to use the same library throughout the project. Here are the two uses of gms:
1) Main activity has dependency on 'CastCompanionLibrary-android-master' which then uses google-play-services_lib. I'm not sure which version of gms this uses, but the version number is referenced in the manifest. Is this just grabbing the version # of play services that they have installed on their phone?
2) BaseGameUtils - has dependency on com.google.android.gms:play-services:+ (I think this is grabbing the most recent version of play-services, but doesn't match the other one.
MainActivity gradle file
dependencies {
compile project(':BaseGameUtils')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CastCompanionLibrary-android-master')
}
CastCompanionLibrary-android-master dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-support-v7-appcompat')
compile project(':android-support-v7-mediarouter')
compile project(':google-play-services_lib')
}
BaseGameUtils dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:+'
}
So, the problem (I think) is these two versions of com.google.android.gms, but how do I rectify it so that they all use the same version. I've had almost 2 years of working with Android, but this is my first question on stack overflow. Help is appreciated - Is there a guru out there that has the answer to this?
Seems like you have modified the gradle file for CCL since what you have there does not match with what CCL has in GitHub. The best approach is to only use the piece of play services that you need; for example CCL only needs the play-services-cast (besides the base, which will be pulled in automatically) so if you follow that pattern, things would look smaller (less possibility of running into the 64K dex limit) and less collisions.CCL, in Github, lists its dependency as:
compile 'com.google.android.gms:play-services-cast:6.5+' so you might want to start using versions and also follow the recomendation I just made (same applies for any other code that you have and uses play services; just pull in what you really need)