Manage Android dependencies versions using gradle extra properties.
SF
July 29, 2016
This is yet another tip you can use in improving your Android development experience
and speed.
We all love dependencies right? Yes we do!
A typical Android studio project (you can stop reading now if you still use Eclipse ๐ seriously)
has a project level build.gradle file and as many module-level build.gradle as there are modules.
Dependencies are usually managed at the app-module level, and your app-module build.gradle file
can quickly get messy from dependencies. It gets even worse, when you have other modules you reference
in your app-module, each with its own dependencies.
In this post, I'll show a quick way of making things look neat, and easy to maintain.
Externalize hardcoded values.
Let's say our project's app-module build.gradle looks like this:
You can see that we've repeated quite a number of versions, including the
android support libraries.
What we want to do is to externalize hardcoded values in our build.gradle file by
leveraging gradle's extra properties.
We can extract these hardcoded into an ext block. Our build.gradle file will now look like this:
Discussion in the ATmosphere