Documentation section

How to fix: prefer settings repositories over project repositories

Learn how to use Localazy with repositories defined in settings.gradle.

Recently, Android introduced a new way how to define repositories. Instead of your build.gradle, you should place them into settings.gradle. It collides with how the Localazy Gradle plugin adds its repository, and you end up with this error message:

Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by plugin 'com.localazy.gradle'

There are two possible solutions for this issue.

Disable repositories in settings.gradle 🔗

This approach allows the Localazy Gradle plugin to manage repositories on its own, and you don’t need to care about it.

Comment out repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) in the settings.gradle file:

dependencyResolutionManagement {
    // repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

And be sure to add the repositories section to your build.gradle manually.

Adding Localazy repository manually 🔗

In your build.gradle file, tell Localazy to don’t add its repository automatically:

// ... your build.gradle file ...

localazy {
	// ... your Localazy configuration ...
  injection {
    installRepositories false
  }
}

And add Localazy repository to your settings.gradle:

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    google()
    mavenCentral()
    maven { url "https://maven.localazy.com/repository/release/" }
  }
}