Showing posts from July, 2015

How to centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:
root --gradleScript ----dependencies.gradle --module1 ----build.gradle --build.gradle In gradleScript/dependecies.gradle:

ext { //Version supportLibrary = '22.2.1' //Support Libraries dependencies supportDependencies = [ design : "${supportLibrary}", recyclerView : "${supportLibrary}", cardView : "${supportLibrary}", appCompat : "${supportLibrary}", supportAnnotation: "${supportLibrary}", ] } In the top level file build.gradle:

// Top…

A First Glance at Stetho tool

I decided to spend a few hours on Stetho.
Stetho is a sophisticated debug bridge for Android applications.

How to enable it
It is very simple to enable Stetho.
Just add these lines to your build.gradle: dependencies { // Stetho core compile 'com.facebook.stetho:stetho:1.1.1' //If you want to add a network helper compile 'com.facebook.stetho:stetho-okhttp:1.1.1' } Then in your Application you can enable the tool just adding:
Stetho.initialize( Stetho.newInitializerBuilder(this) .enableDumpapp( Stetho.defaultDumperPluginsProvider(this)) .enableWebKitInspector( Stetho.defaultInspectorModulesProvider(this)) .build()); In my simple application, I have a network call with okhttp-client , a simple value in the shared preferences, and a small db with one table.
Now the last step: Ru…

Gradle tip: how to use the archivesBaseName to change the apk name

I am seeing a lot of build.gradle where there are tasks to rename the apks.

I prefer using something different, without use another tasks, setting the archivesBaseName.

For example:

defaultConfig { .... project.ext.set("archivesBaseName", "MyName-" + defaultConfig.versionName); }