Does "play-services:9.8.0" include "play-services-location:9.8.0"?
Asked Answered
O

2

-1

I am upgrading an App, and in my build.gradle file, I have this:

dependencies {
    ..........
    compile 'com.google.android.gms:play-services:9.8.0'
    ..........
}

In the Android SDK Setup Quickstart Guide Urban Airship provides, they offer this as a sample code:

dependencies {
    ..........
    // Recommended for location services
    compile 'com.google.android.gms:play-services-location:9.8.0'
    ..........
}

If I use "play-services:9.8.0" I would assume it would also include "play-services-location:9.8.0" because "play-services-location:9.8.0" should be a subset of "play-services:9.8.0", but I wanted to confirm. Do you know if this is a correct assumption? Thank you.

Overweigh answered 30/3, 2017 at 16:30 Comment(4)
why not using the latest: compile 'com.google.android.gms:play-services:10.2.1'Guidance
Sure, so my question is, does "compile 'com.google.android.gms:play-services:10.2.1'" include "compile 'com.google.android.gms:play-services-location:10.2.1'"? The purpose of my question is not to focus on a specific version, but just to confirm if importing "play-services" would include everything you also have in the case of importing "play-services-location", assuming that "play-services-location" is a subset of "play-services", since "play-services" would be the superset.Overweigh
its better to use the most fragmented piece of the lib, to avoid code that you dont need =)Blessington
I know, you are absolutely right, but I just wanted to confirm if importing "play-services" would include everything you have when you use "play-services-location", but it looks like the answer is yes.Overweigh
M
1

Yes, play-services is the full bundle. They were broken apart to reduce the method count of your app so you don't hit the dex limit. More information can be found here.

Malachy answered 30/3, 2017 at 16:44 Comment(1)
I can see what you mean from the reference you sent (developer.android.com/studio/build/multidex.html): "A common anti-pattern is to include a very large library because a few utility methods were useful. Reducing your app code dependencies can often help you avoid the DEX reference limit."Overweigh
G
3

From Google Api Documentation

you can use the latest Google play service api:

 dependencies {
    compile 'com.google.android.gms:play-services:10.2.1'
}

If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.

enter image description here

To Selectively compiling APIs into your executable:

 compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-plus:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-games:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'

the detail lists are provided in the documentation.

Guidance answered 30/3, 2017 at 16:43 Comment(5)
I see. Actually the limit is 64K, not 65K, as stated at developer.android.com/studio/build/multidex.html.Overweigh
i added from the google api documentation..on the link i providedGuidance
I was reading the "Avoid the 64K limit" heading at developer.android.com/studio/build/multidex.html#avoid. 64K or 65K, I get the point. Thank you for your answer.Overweigh
You are right about the limit...Because 65,536 is equal to 64 X 1024, this limit is referred to as the '64K reference limit'..i don't know why they put 65K in there.Guidance
Yes, that makes sense.Overweigh
M
1

Yes, play-services is the full bundle. They were broken apart to reduce the method count of your app so you don't hit the dex limit. More information can be found here.

Malachy answered 30/3, 2017 at 16:44 Comment(1)
I can see what you mean from the reference you sent (developer.android.com/studio/build/multidex.html): "A common anti-pattern is to include a very large library because a few utility methods were useful. Reducing your app code dependencies can often help you avoid the DEX reference limit."Overweigh

© 2022 - 2024 — McMap. All rights reserved.