How to import ** some ** parts of the guava library into an Android application (gradle)

As any Android developer should know, there is a 65k limit for your apk (because the VM has only 16 bits to process methods). It is quite difficult to achieve, but easy as soon as you start adding some libraries.

From last year, you can get rid of this by enabling MultiDex on Android 5.0 and higher (and adding a support library for previous versions of Android). Even when possible, it is always best to reduce the number of methods and get a smaller api (and performance should be better, right?).

At some point, the guys from Android realized that the size of their Google Play Services library was not available (20 thousand methods), and they made a great decision to divide it into different modules , so you can just add the parts you need (with a degree):

compile ('com.google.android.gms:play-services-analytics:8.1.0') compile('com.google.android.gms:play-services-appindexing:8.1.0') 

Do you know if you can do something like this using the Guava library? This is about 15 thousand methods, so it will be very useful. I would like to use only a small part of Guava, so I don't need / don't need to include another. I searched the documentation and search engine but nothing was found.

 compile group: 'com.google.guava', name: 'guava', version: '18.0' 

Some guy asked something like this two years ago, perhaps for a Java project, but then there were no smaller parts of guava. Download part of guava libraries

The only thing that comes to my mind is to copy only the necessary Guava classes instead of loading the library, but I find this a terrible solution.

Do not you think that any large library should use a module separation system, as it was in Play Services?

EDIT . In addition, the multidex task takes too much time (one minute and a half, when it used to be less than 15 seconds), so every time I want to run the application, I have to wait. Thus, even when using Proguard - an excellent solution for the release of products, it is not suitable for development, as it takes more time than multidexing.

+8
android guava gradle
source share
1 answer

Work is ongoing to improve Guava on Android , but there are no plans to split it into smaller modules . As already mentioned, ProGuard allows you to exclude parts of Guava that you are not using from your final build.

+1
source share

All Articles