I’m encountering an issue with my Gradle build in Android Studio. The build fails with the following error message:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-
Where:
Build file ‘C:UsersMalekAndroidStudioProjectsCoursebuild.gradle.kts’ line: 16 -
What went wrong:
Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘build.gradle.kts’ -
Try:
Run with –info or –debug option to get more log output.
Run with –scan to get full insights.
Get more help at https://help.gradle.org.
- Exception is:
org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘MavenRepo’ was added by build file ‘build.gradle.kts’
at org.gradle.internal.management.DefaultDependencyResolutionManagement.repoMutationDisallowedOnProject(DefaultDependencyResolutionManagement.java:199)
This error suggests that my build configuration is set to prefer settings repositories, but a repository (‘MavenRepo’) was added in the project build file build.gradle.kts on line 16. I’ve tried running with the –info and –debug options but haven’t been able to resolve the issue. Any suggestions on how to fix this conflict would be greatly appreciated.
I tried following a solution I found on YouTube, which suggested removing the repository declaration from the build.gradle.kts file. However, despite removing the MavenRepo repository as instructed, I am still encountering the same error. I expected this change to resolve the conflict between the settings repositories and project repositories, but the build continues to fail with the same message.
Malek.A Zhr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.