Android Gradle build is failing with the exception "you cannot configure authentication schemes for this repository type if no credentials are provided"

Hi,

We are trying to migrate the repository declaration from build.gradle file to settings.gradle file but our gradle build start failing. We are using Azure Artifact Feed to download our dependency and for Maven Authentication , we are using net.linguica.maven-settings plugin.

Gradle Version: Gradle 7.3.3

Build was working fine with the following old-settings:
##############################################

build.gradle:



plugins {
id “net.linguica.maven-settings” version “0.5”
}

repositories {
maven {
url ‘https://pkgs.dev.azure.com/Suchkan/_packaging/My-demo-Feed/maven/v1’
name ‘My-demo-Feed’
authentication {
basic(BasicAuthentication)
}
}
}

In app/build.gradle:



apply plugin: ‘net.linguica.maven-settings’

settings.gradle:

include ‘:app’

#####################################################################

After migrating repository declaration to settings.gradle, maven authentication to Azure Artifact Feed for downloading maven package stop working. Here is the changes that was done.

build.gradle:


plugins {
id “net.linguica.maven-settings” version “0.5”
}

// allprojects {
// repositories {
// maven {
// url ‘https://pkgs.dev.azure.com/Suchkan/_packaging/My-demo-Feed/maven/v1’
// name ‘My-demo-Feed’
// authentication {
// basic(BasicAuthentication)
// }
// }
// }
}


settings.gradle:

include ‘:app’

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {

maven {
url ‘https://pkgs.dev.azure.com/Suchkan/_packaging/My-demo-Feed/maven/v1’
name ‘My-demo-Feed’
authentication {
basic(BasicAuthentication)
}
}

}
}

In app/build.gradle:


apply plugin: ‘net.linguica.maven-settings’

##########################################
Exception:

Task :app:loadKtlintReporters FAILED
:app:loadKtlintReporters (Thread[Execution worker for ‘:’,5,main]) completed. Took 0.062 secs.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:loadKtlintReporters’.

Could not resolve all dependencies for configuration ‘:app:ktlint’.
You cannot configure authentication schemes for this repository type if no credentials are provided.

Can you let us know how to resolve the plugin dependency when using setting.gradle file?
Did anyone face this issue. Can someone guide how to fix it?

A quick look at net.linguica.maven-settings shows, that his plugin is not compatible with repositories in dependencyResolutionManagement.
You would need to post a feature request to that plugin to support it if you need its functionality, or to rewrite your stuff to not need what it provides.
As a work-around to still centralize the repositories without using cross-project configuration, you can write a convention plugin that adds your repositories and then apply that convention plugin to your projects.