8

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.

Kalyan Dechiraju
  • 1,219
  • 1
  • 11
  • 29
  • Possible duplicate of [Lint: "Newer Library Versions Available" when using variables](https://stackoverflow.com/questions/46295985/lint-newer-library-versions-available-when-using-variables) – ToYonos Jun 08 '18 at 10:40
  • It is not a duplicate. Please see my updated question. – Kalyan Dechiraju Jun 12 '18 at 05:55

2 Answers2

1

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

stewemetal
  • 138
  • 8
  • I am looking for a solution inside Android studio rather than some plugin or script. Even I am using AS 3.1.2 and I never got an update warning! Interesting. – Kalyan Dechiraju Jun 08 '18 at 13:39
  • Thanks, I didn't know about this and it's really useful. Finally I can see warnings again. The plugin in the mentioned answer is not working for me with Gradle 4.6 and Gradle plugin 3.2.1 - I'm getting error `Resolving configuration 'androidTestAnnotationProcessorCopy' directly is not allowed.` – Micer Nov 03 '18 at 21:54
0

You can extract dependencies versions into variables stored in a separate Gradle file and then check and update them from the Project Structure (ctrl+alt+shift+S) (screenshot from Android Studio 3.6.3):

enter image description here

Dragos
  • 51
  • 4