Gradle composite builds with custom repositories in Android Studio

Viewed 262

Our company requires we have all our dependencies downloaded from our internal repository (Artifactory). Our Android project has the main Android modules, plus composite builds.

I was able to replicate the issue creating a simple project from Android Studio, and adding a composite build (or buildSrc) into it. More or less like this (I didn't include the other files above to keep it simple):

project
 ├─ app                    (<-- application module)
 ├─ plugins                (<-- composite build )
 │  ├─ settings.gradle.kts (<-- settings for composite build)
 ├─ settings.gradle.kts    (<-- settings for main project)

Both settings.gradle.kts (main + composite build projects) have something like this (again, leaving irrelevant elements out of it):

pluginManagement {
   repositories{
       maven(url="https://artifactory.mycompany.org")
   }
}

dependencyResolutionManagement {
   repositories{
       maven(url="https://artifactory.mycompany.org")
   }
}

This works perfectly while running from terminal (e.g. ./gradlew build), but the sync operation via Android Studio seems to always trigger dependencies download from *.gradle.org. After the sync, all the other project dependencies for build operations seem to work on Android Studio. If I create a project without composite builds (or buildSrc) it seems the issue doesn't happen.

This has been creating many issues, as you can imagine, but it doesn't seem that many people have been reporting the exact same experience. Apart from the issue of downloading dependencies from a different repository, it is also downloading these dependencies multiple times during the day.

I've also checked environment variables, Java SDK, etc to match between Android Studio and terminal, and Android Studio is also configured to use gradle from "gradle-wrapper.properties".

Has anyone faced similar issue, and has any clues on what else I could be missing? Or could that be an issue on the Android Studio gradle plugin?

0 Answers
Related