Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct way to move gradle dependency versions to a variable?

Tags:

android

gradle

In order to maintain the version numbers of my gradle dependencies, I chose the below pattern.

In my project level build.gradle I added:

ext.versions = [
            'kotlin_version'   : '1.2.30',
            'dagger'           : '2.16'
]

And in my app module's build.gradle I added:

implementation "com.google.dagger:dagger:${versions.dagger}"
implementation "com.google.dagger:dagger-android-support:${versions.dagger}"
implementation "com.google.dagger:dagger-android:${versions.dagger}"
kapt "com.google.dagger:dagger-compiler:${versions.dagger}"
kapt "com.google.dagger:dagger-android-processor:${versions.dagger}"

But my problem is after doing this, I lost the lint warnings of "Newer Library versions available".

What is the correct way to do this without missing the lint checks?

Note: I have also tried other ways like moving these versions to gradle.properties file (for global variables).

I am looking for a solution inside Android Studio. There is one solution which I already found:

Analyze -> Run Inspection by name... -> Type "Newer Library Versions Available"

But my concern is, it is easy to miss on updates until we run some or the other script. That is why I am trying to find a way where dependency versions can be put in a variable and get lint warning for new updates.

like image 490
Kalyan Dechiraju Avatar asked Jun 08 '18 10:06

Kalyan Dechiraju


1 Answers

See this answer: https://stackoverflow.com/a/46296198/2053763

There is a link to a gradle plugin which can check for dependency updates.

Android Studio 3.1.2 offers some lint checks while using version variables, but still misses some of the updates. See image below:

enter image description here

like image 52
stewemetal Avatar answered Nov 05 '22 06:11

stewemetal