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 { jcenter() mavenCentral() } } ... dependencies { compile group: 'com.google.guava', name: 'guava', version: '18.0' .... other dependencies.... }
I also need to add a new file into the projects called progurard-guave.pro and add that to the release building portion of gradle:
buildTypes { release { minifyEnabled true // Library specific proguard files proguardFiles 'proguard-guava.pro' //Default proguard file proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }
Just an FYI: do not trust the contents of proguard-guava.pro yet. I am saving the real work on the file for later once the development is done.
No comments :
Post a Comment