This is certainly possible. In your projects build.gradle file (the top level build.gradle file) add the following code block:
ext {
supportlib_version = '26.1.0'
gps_version = '11.2.0'
}
//Ensure that all dependencies use the same version of the Android Support library
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$supportlib_version"
}
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$gps_version"
}
}
}
}
The following code ensures that the ‘com.android.support’ dependency version will be equal to $supportlib_version for all dependencies. The same for the ‘com.google.android.gms’ framework.
Make sure that in your module’s build.gradle file you also use these versions for your dependencies. E.g.:
compile "com.android.support:support-v4:$supportlib_version"
Read more about forcing a certain dependency version in the Official Gradle documentation.
Update
Google has decoupled library versions. Therefore, forcing a specific version above 15.0.0 may not work. Instead, you can allow a limited range of versions. The example below allows any version higher than 15.0.0 but lower than 16.
gps_version = '[15.0.0, 16.0.0)'