How can I see dependency updates in build.gradle when using variables?

Viewed 178

Android studio will show you if there is a newer version of a library when the version number is hard coded. But if you use variables, this seems to short circuit that functionality. Is there any way to get it back? I want to see available updates in build.gradle without having to Inspect the project.

enter image description here

1 Answers

Gradle 6 offers a new way to recommend and share versions between projects called platforms. This allows you to specify a set of dependency versions to share across projects without using variables.

You can use the Java Platform Plug-in to create a platform; a special kind of project that only contains a list of dependencies that work together. I haven't tried this, but hopefully Android studio will alert you if any of these versions are out of date since you'll be using hard coded version numbers.

You can then reference your platform in your other projects using the platform keyword and load all the other dependencies without versions

dependencies {
    // get recommended versions from the platform project
    api(platform(project(":platform")))
    // no version required
    api("commons-httpclient:commons-httpclient")
}
Related