Reputation: 489
I have a project with 1 app module (MyApplication) and 1 library module (core). When I'm trying to see 'gradlew MyApplication:dependencies', i'm having an error
* What went wrong: A problem occurred evaluating project ':core'.
> Cannot change dependencies of configuration ':core:classpath' after it has been resolved.
In top-level directory I have build.gradle with this:
...
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven {
url 'https://maven.fabric.io/public'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
...
and also I set
org.gradle.configureondemand=true
In MyApplication directory I have build.gradle with typical application configuration
apply plugin: "com.android.application"
...
In core directory I have build.gradle with this:
...
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
}
...
Please ask if additional information from gradle files is needed.
I'm sorry it's project have limitations on disclosure of source code and whole gradle files body.
Upvotes: 1
Views: 2982
Reputation: 489
Finally I understood what's coming wrong. In top-folder build.gradle we already defined stuff related to android build tools:
buildscript {
repositories {
google()
maven {
url 'https://maven.fabric.io/public'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
So we need to delete this definition from application or library modules:
apply plugin: "com.android.library"
apply plugin: "maven"
apply plugin: "maven-publish"
ext.getArtifactId = {
return "core"
}
if(project.hasProperty("PATH_SET_VERSION") == true){
apply from: project.property("PATH_SET_VERSION").toString()
}
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
mavenLocal()
maven {
url "our local repositiry"
}
maven {
url "https://google.bintray.com/flexbox-layout"
}
}
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1' // it's not needed here, so better to delete this dependencies {...} section
}
}
Upvotes: 1