Does “play-services:9.8.0” include “play-services-

2019-06-14 17:43发布

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.

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-14 17:53

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.

查看更多
Explosion°爆炸
3楼-- · 2019-06-14 17:58

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.

查看更多
登录 后发表回答