Wednesday, February 25, 2015

MyNotes: Fruit Based Libraries

As you might have noted from the last commits, I brought in the Guava library.  There are two schools of thought on Guava with Android:  Do it or Avoid at all cost.

I am ambivalent on the subject.

I don't like bringing in large libraries because they push your app towards the dreaded 65k method limit.  Android has provided ways to mitigate the issue, but I don't like getting close to it. Guava is a big library and that has to be take into consideration.

On the other hand, I don't have the time or resources to reinvent the wheel or keep it turning when it comes to the functionality that Guava gives me.

After waffling for awhile, I decided to include Guava.  This means that I will need to use Proguard ot shrink the library to only those classes that I am using.  It also means I have to be more careful in my release testing to make sure the Proguard minimazation works and that I am not including more of Guava than I need.

To bring in Guava with Gradle, you need to add MavenCentral as a valid repository and then add the dependency.  It ends up looking like this:

allprojects {
    repositories {

dependencies {
    compile group: '', name: 'guava', version: '18.0'

   .... other dependencies....

I also need to add a new file into the projects called and add that to the release building portion of gradle:
buildTypes {
  release {
    minifyEnabled true

    // Library specific proguard files
    proguardFiles ''

    //Default proguard file
    proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

Just an FYI:  do not trust the contents of yet.  I am saving the real work on the file for later once the development is done.


You can find the changes for this entry among the commit at

No comments :

Post a Comment