DEV Community

Cover image for Matt's Tidbits #58 - A strange issue when upgrading to Android Studio 3.6
Matthew Groves
Matthew Groves

Posted on • Originally published at Medium

Matt's Tidbits #58 - A strange issue when upgrading to Android Studio 3.6

Last time I wrote about how to improve RxJava stack traces. This week, I want to highlight a potential issue you may run into when upgrading to Android Studio 3.6.

Android Studio 3.6 launched on February 24, and brings a number of updates. You can read more about them here:

Always one to keep my software as up-to-date as possible, I downloaded the update and installed it. So far, the IDE is working great! However, as usually happens when there’s a new release of Android Studio, there’s also an update to the Android Gradle plugin.

You have almost certainly seen this dialog box pop up before:

I despise annoying pop-ups, so I clicked the update button. Android Gradle Plugin updates are usually safe!

However, what I discovered is that my code would no longer compile!

The Java code that wouldn’t compile looked like this:

public class MyWorker extends Worker {...}

The compiler was complaining that Worker’s constructor has 2 arguments, and my code isn’t specifying either of them. What is going on here?

I double-checked, and the only change had indeed been moving the Android Gradle Plugin version from 3.5.3 to 3.6. I found the library import for the Worker class, and it was this:

implementation ""

So, I pulled up the documentation for that version of the Worker class, and everything looked fine. However, I also noticed that this version of the WorkManager library is over a year-and-a-half old — the newest version is 2.3.2! Version history for this library is here:

I dug in a little more and ran the gradle app:dependencies command to see what my dependencies were, and sure enough, both the older work-runtime library as well as*:2.0.0 was also listed. Oddly enough, it was listed as a top-level dependency.

Most importantly, in this newer version of the library, the API for the Worker class has changed, and will no longer compile.

The pieces all fell into place — the latest Android Gradle plugin (3.6) has a dependency on a newer version of the WorkManager library, and because of how my Gradle configuration was set up, this newer version overwrote my older one!

To complete the research, I downgraded back to Android Gradle Plugin 3.5.3 and found that the same version I had been including (1.0.0-alpha05) was included as a top-level dependency. So, my guess is that the Android Gradle Plugin itself had been using WorkManager, and the new version has upgraded to the newer version, leaking that dependency into my app.

I spent a short amount of time trying to figure out how to get that dependency to go away (or to force it to use my older version), but decided this wasn’t worth it, and we should just upgrade — we had been using an alpha version anyways!

I hope you learned something that saves you a little time when upgrading to Android Gradle Plugin 3.6! If you’re a Gradle wizard, how would you have resolved this? Let me know in the comments below! And, please follow me on Medium if you’re interested in being notified of future tidbits.

Interested in joining the awesome team here at Intrepid? We’re hiring!

This tidbit was delivered on February 28, 2020.

Top comments (0)