如何从 Google Play 服务中识别和导入特定库?
How do I identify and import only specific libraries from Google Play Services?
我目前的依赖项中有以下行:
编译'com.google.android.gms:play-services:4.2.42'
当我刚开始编写我的应用程序代码时,我把它放在了 longhn 中,现在我意识到这可能是导致我的应用程序膨胀到大约 20 MB 的原因
有没有办法识别并专门导入必要的服务以减小我的应用程序大小?我很确定有一些方法可以只导入特定的模块,但也有关于如何识别我需要哪些模块的指示将不胜感激
首先,您需要检查您的项目并确定使用了哪些 Play 服务模块。然后,您可以有选择地添加项目所需的播放服务 API。
例如:以下将向您的应用添加 Google 分析和地图模块。
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'
}
你可以使用这样的东西
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
从 6.5 版开始,您可以有选择地将 Google Play 服务 API 编译到您的应用中,
例如,要仅包含 Google Fit 和 Android Wear API,请在 build.gradle 文件中替换以下行:
compile 'com.google.android.gms:play-services:8.4.0'
这些行:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
请检查这个link
我目前的依赖项中有以下行:
编译'com.google.android.gms:play-services:4.2.42'
当我刚开始编写我的应用程序代码时,我把它放在了 longhn 中,现在我意识到这可能是导致我的应用程序膨胀到大约 20 MB 的原因
有没有办法识别并专门导入必要的服务以减小我的应用程序大小?我很确定有一些方法可以只导入特定的模块,但也有关于如何识别我需要哪些模块的指示将不胜感激
首先,您需要检查您的项目并确定使用了哪些 Play 服务模块。然后,您可以有选择地添加项目所需的播放服务 API。
例如:以下将向您的应用添加 Google 分析和地图模块。
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'
}
你可以使用这样的东西
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
从 6.5 版开始,您可以有选择地将 Google Play 服务 API 编译到您的应用中, 例如,要仅包含 Google Fit 和 Android Wear API,请在 build.gradle 文件中替换以下行:
compile 'com.google.android.gms:play-services:8.4.0'
这些行:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
请检查这个link