Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘ 2023. If you are facing maven repository error in your android studio then you are at the right place.
Where to add maven dependency in Bumblebee, Chipmunk, or any other latest android studio versions? You are getting maven_repository is undefined or any type of error in maven dependency or repository.
Then don’t worry you are in right place.
I will tell you what is the main reason behind it and how we can solve this error. Are you facing a maven error or jitpack error? Then don’t worry, we will solve the maven or jetpack error within seconds.
This error is called Maven Repository error, more likely it’s not an error, we are just misplacing the files. In Older versions of android studio, we have the option to add maven or mavenControl to all project’s repositories, but in newer versions, it is not allowed moreover jcenter() is deprecated.
Solution for undefined maven_repository error or where to put maven dependency:
- Just put your maven dependency code in settings.gradle file dependencyResolutionManager() method and sync it. This is the solution for almost all maven_repository errors and it also answers the question of Where to put maven code in the latest versions of the android studio like the bumblebee, chipmunk, etc.
- Please see the below screenshot to get a better idea of what to do.
How to Solve Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘ 2023
Steps to fix maven repository or dependency error are:
- Open Gradle Scripts in your project.
- Click on settings.gradle
- Search for dependencyResolutionManger() method in settings.gradle. Paste your maven code in the repository section of that file. (See the below image.)
- Click Sync now.
- This is all that you need to make work maven code in android studio chipmunk or bumblebee or any other latest versions.
Where to put maven code screenshot image
In this article, we have learned about where to put maven code in the android studio versions higher than bumblebee and chipmunk. We can solve the maven repository error Build was configured to prefer settings repositories over project repositories but repository ‘maven’ was added by build file ‘ in just a few seconds. For more understanding, you can refer to the android website.
Many of us have faced this error and want resolvent it as soon as possible so this is the shortest way to get it resolved. Hope you will get your solution from here.
Add maven repository to build.gradle, how to add maven dependency to build.gradle, add maven dependency to settings.gradle.