I wonder if there is a way to customize google-play-services.jar
.
Google play services version 6.1
I found that new version has 24K methods that makes my application out of Max method count (~65K) and therefore I can't create APK file (or DEX).
In the past I saw on some site that you can configure google-play-services.jar
by enable/disable
unused features.
My old jar weight is 7K (instead 19K) and I can't jump to 24K, too expansive.
Any suggestions please?
[EDIT]
I found this question where @Eric Lafortune
suggests to use Proguard
Google Play services helps to ensure the security and reliability of an Android device, and keep devices updated with the latest security features. This includes: Google Play Protect, which can warn users if an app contains known malware.
Google Play services offers APIs to other apps. Data used by Play services is mostly cached data for these APIs, duplicated data of Android wear apps synched with your phone and some kind of search index.
Ideally you should use ProGurad, however you can follow these two steps:
Step 1: Remove unused classes from jar file
Open the google-play-services.jar in the library project with a zip file manager such as Winrar or 7zip. You will find many folder such as maps, games
, just delete the ones you don't need. Make sure you keep common, dynamic, internal
.
Step 2: Remove unused resource from res folder
Most of the resources in the google-play-services_lib\res folder might be of no use so you can remove it. These include values-af, values-am,
.... what you need to keep is color, drawable, drawable-hdpi
and values
folder.
Refresh and build the google-play-services_lib project and your project. Your apk size should be decreased.
In Android Studio You can use individual library from google play service such as
compile 'com.google.android.gms:play-services:7.5.0'
with these lines:
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
complete list is available here https://developers.google.com/android/guides/setup
Some APIs do not have a separate library; include them by including the base library
Keeping in mind that:
If you are using Gradle and just want to exclude automatically the parts of Play Services that you don't use, this is the easiest, fastest, and most efficient way: https://gist.github.com/Takhion/10a37046b9e6d259bb31.
Just add it as suggested and comment the exclude
on the parts that you need!
Sooo useful for debug builds where you don't want to go through Proguard each time ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With