Trying to add jitpack.io repo in setting.gradle but I am facing the following error: Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ in android. In this Exerror article, We are going to learn about How to reproduce this error and we will discuss All Possible Solutions Let’s Get Start With This Article.
- How Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error Occurs?
- How To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error?
- Solution 1: Add maven in dependencyResolutionManagement
- Solution 2: Remove
dependencyResolutionManagement
- Solution 3: Use RepositoriesMode as PREFER_SETTINGS
- Conclusion
How Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error Occurs?
Trying to add jitpack.io repo in setting.gradle but I am facing the following error.
Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
So here I am writing all the possible solutions that I have tried to resolve this error.
How To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error?
How To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error?
To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error Second Solution is You Just need to Remove dependencyResolutionManagement From Your setting.gradle and then After your Gradle Sync, Your error Should be solved. Thanks.
Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’
To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error You Just need to add maven URL as https://jitpack.io/ in your dependencyResolutionManagement as a repository. And now, After your Gradle Sync, Your error will be solved. Thank You.
Solution 1: Add maven in dependencyResolutionManagement
To Solve Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘build.gradle’ Error You Just need to add maven URL as https://jitpack.io/ in your dependencyResolutionManagement as a repository Just Like This.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
And now, After your Gradle Sync, Your error will be solved. Thank You.
Solution 2: Remove dependencyResolutionManagement
Second Solution is You Just need to Remove dependencyResolutionManagement From Your setting.gradle and then After your Gradle Sync, Your error Should be solved. Thanks.
Solution 3: Use RepositoriesMode as PREFER_SETTINGS
If Above both solution is not working then You need to use RepositoriesMode as PREFER_SETTINGS Just like this.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
}
Now, Your error will be solved. Thanks.
Conclusion
It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below on which solution worked for you.
Also, Read
- mysql.connector.errors.ProgrammingError: Character set ‘utf8’ unsupported
- Error: error:0308010C:digital envelope routines::unsupported
- Error: A is only ever to be used as the child of element
- [ERR_REQUIRE_ESM]: require() of ES Module from not supported
- Impish Release no longer has a Release file