How to decrease google-play-services.jar size?

I use in my custom android extension google-play-services.jar library. I use it only for showing ads.
In gradle projects we can include only specific API like that:

compile ''

In lime extensions we include full library as jar file:

<java path="dependencies/android/libs/google-play-services.jar" />

And size of my application is increased on ~5Mb. Furthermore, i got 65K methods error today :confounded:
How can i use only needed API from the library?

A jar is just fancy a zip file. I remember for one project I went in and deleted a load of classes to do with chromecast and wear and a load of other classes I knew I wouldn’t use and everything still worked. Work iteratively though - delete a few things and test each time to avoid deleting too much and having to start again.

I’m afraid i can broke some api functions…
Now i trying to optimize the jar through proguard. If this doesn’t help, i will try to delete classes manually =)

At first, it super strange that you got 65K methods error just by including google play services.
OpenFl / Lime adds few java classes and methods. Maybe you include some other java libraries?

(Moreover, at my primary work I write android apps on java, with many classes and methods, I use google play services everyday, and never seen 65K methods error).

Secondly, you can find play-services-ads inside android sdk dir : %android_sdk_root%/extras/google/m2repository/com/google/android/gms/play-services-ads/8.3.0/play-services-ads-8.3.0.aar

Unfortunately this is aar, not jar. But aar is just a zip file, and it has classes.jar inside.
Probably you can convert it to standard android library -

1 Like

Yes, projects has few java libraries. But gps is the biggest of them and contains too many useless for me methods.
Your advice with .aar files works fine for me! Thank you! :grinning:

Google is deprecating the ant build process, so we are going to have to look at moving to Gradle anyway in the future. Hopefully it doesn’t break all our extensions :slight_smile:

1 Like

Do you have any date when we can test gradle build system?