skip to Main Content

I am investigating the automation of keeping my teams android applications gradle deps up to date.

what caused me to look into this was that Android studio highlighted that there is a more recent version of com.google.android.material:material:1.9.0-beta01 e.g. com.google.android.material:material:1.10.0-alpha01, however when I upgraded this dependency my build failed with:-

An issue was found when checking AAR metadata:

  1.  Dependency 'com.google.android.material:material:1.10.0-alpha01' requires libraries and applications that
      depend on it to compile against codename "UpsideDownCake" of the
      Android APIs.

      :app is currently compiled against android-33.

      Recommended action: Use a different version of dependency 'com.google.android.material:material:1.10.0-alpha01',
      or set compileSdkPreview to "UpsideDownCake" in your build.gradle
      file if you intend to experiment with that preview SDK.

why does android studio highlight a dependency upgrade that is not valid for my targetSdk?

Is there an Android Studio "feature" that I can employ to only have dependency upgrade recommendations for valid versions?

or

Is my only option to manually check all versions are valid for my current targetSdk version

2

Answers


  1. There are a few options for automation of dependency management with compatibility checks. My personal recommendation is Dependabot.

    1. Use Dependabot or Gradle Versions Plugin: One option is to use a dependency management tool such as Gradle Versions Plugin or Dependabot. These can detect outdated dependencies and even generate PRs, and can even configs for your minSdk and targetSdk versions’ incompatibilities. If you use GitHub repo for your project, add Dependabot from marketplace (for free), and that’s it, it will generate PRs for version bumps, and it also checks for NPM/PIP/Cargo etc. and security too!

    2. Jenkins/Travis CI: These CIs can automatically build and test your project with the latest version of your dependencies (In PRs). This can help you catch any compatibility issues early on and avoid build failures or app crashes in production.

    Android Studio will highlight all dependency upgrades (which may be invalid, like in your case), it’s better to disable them in settings and use a reliable dependency manager.

    Login or Signup to reply.
  2. Android Studio sometimes suggests the latest dependency version without considering compatibility with your project’s targetSdk or compileSdk. This can be confusing and lead to build failures if the new dependency isn’t compatible.

    You can’t rely solely on Android Studio’s recommendations to avoid this issue. Instead, you can do the following:

    1. Manually check the release notes or documentation of the library you
      want to update. This will help you understand if the new version is
      compatible with your project’s targetSdk and compileSdk.
    2. Use a third-party tool like Gradle Versions Plugin to get a list of
      available updates for your project’s dependencies. This plugin can
      help you see available updates, but you’ll still need to check
      compatibility before applying them.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search