We have an Android project with around 90 library modules. This question is about Dependency resolution. This phase mostly took around 10 - 20 seconds on some machines. Also, it looks like it took sometimes slightly more time with each build.
What is main contributor to longer times here? Is it mainly “implementation xyz”, “api xyz” in our modules in the dependency section in build.gradle files?
When looking here (https://docs.gradle.org/current/userguide/troubleshooting_dependency_resolution.html) we don’t use dynamic versions, we’re using “offline mode” etc. For example, should we avoid using “api xyz” at all cost? We’re using it for dependencies which are already downloaded from artifact repository as aar / jar (they will not be compiled again). Or any other suggestion what could be causing longer execution here except those mentioned in the documentation linked above?
We’re using the newest Gradle (5.6.2), AGP (3.5.1) and so on.
PS: Can’t / shouldn’t be some of the above cached when there is no change to both gradle and kotlin / java / resource files?
we don’t use dynamic versions
Are you sure dynamic dependencies also aren’t used in the transitive dependencies? You can quickly write a resolution strategy which reports all dependecies which contain
+ in the version. I had a case where a single such dependency inflated configuration times by a lot. That said,
--offline should fix that.
Also I’d recommend looking at API to pin the dependencies to specific repositories, especially if you use repositories which might be quite slow.
From my experience every slight dependency resolution performance issue is magnified in the Android projects due to having lots of variants for library modules.
Anyway are you sure that configuration in offline mode also takes so long? Did you time
./gradlew --offline or is it some settings in IDE?
Dynamic dependencies - yes, there can be some for sure. Also, a lot of libraries aren’t using same version for example for AndroidX libraries (support libraries). But “offline mode” should disable those checks if I’m right?
Specific repositories - we have this done already. We are also transferring so dependencies / artifacts to our local and fast repository. But you’re right that some of those dependencies can take quite some time to resolve.
Offline mode - we’re using mainly “offline mode” in IDE (Android Studio) which helps with a few seconds. When I tried “gradlew assembleXyz” with and without “–offline” I got almost exactly same times.
Also do you know something about “api xyz” vs “implementation xyz” in library modules? See the original message.
Thanks a lot for reply.
I’m not aware of any ineffiiences for
api vs implementation in the configuration phase. What external plugins do you use? Doesn’t seem right that dependency resolution takes so long with offline flag :\
Api vs implementation - You mean in the dependency phase? If yes, then ok.
List of external plugins or dependencies: