Is it a good idea to use Google Guava library for Android development?

Oleksandr Karaberov picture Oleksandr Karaberov · Feb 20, 2013 · Viewed 46.5k times · Source

I am involved in the development of Android application which is a rather "thick" mobile client for a Web service. It heavily communicates with the server but also has a lot of inner logic too. So, I decided to use some features of Google Guava library to simplify development process. Here is a list of features I'm very interested in: immutable collections, base utils, collection extensions, functional programming sugar and idioms (common.collect and common.base), primitives utilities (common.primitives), hashing utilities (common.hash), concurrent utils (futures and AsyncFunction). Things I don't want to use in Android: common.cache (see question below), common.eventbus (we have better Android specific libs for this, such as Otto), common.io (we can use okio for Android now).

I read that using Guava for Android can significantly slow down compilation process and also decrease the whole runtime performance: Bad performance with Guava Cache on Android (in this case it is reasonable and there is no need to use Guava's cache for Android) and Adding Google Guava to Android project - significantly slows down the build

So, is it efficient to use Guava library in Android project or this library is designed to be used only for the server-side development, and I should go with standard solutions? Any explanations will be very appreciated.

Answer

Xaerxess picture Xaerxess · Feb 20, 2013

(Too big for comment, so I post an answer.) Personally I use whole Guava library in every Java project and when I don't have significant and properly profiled performance problems. If you do have, for example, memory concerns like in Android environment, you can use ProGuard to get only these parts of Guava you really need.

Moreover, there are many Android apps using Guava - not only small ones, i.e. Google Search and Youtube, which directly come from Google.

(You should also see compatibility note.)