依赖关系解析中包含配置':compile'后,Android无法更改其依赖关系

时间:2018-11-14 12:46:53

标签: android android-studio android-gradle build.gradle

我无法在Android Studio上构建库模块。我在build.gradle文件中遇到以下异常:

Cannot change dependencies of configuration ':smack-android:compile' after it has been included in dependency resolution.

* Where:
Build file '/Users/...../build.gradle' line: 15

我正在使用Android Studio 3.2.1,而Gradle版本是4.6

build.gradle:

dependencies {
    // androidProjects lists all projects that are checked to compile against android.jar
    // Filter out the optional Smack dependencies from androidProjects
    androidProjects.findAll {
        ![':some-module'].contains(it.getPath())
    }.each { project ->
        compile project // Line no 15 exception occurred
    }
}

compileJava {
    options.bootClasspath = androidBootClasspath
}

// See http://stackoverflow.com/a/2823592/194894
// TODO this doesn't seem to work right now. But on the other hand it
// is not really required, just to avoid a javadoc compiler warning
javadoc {
    options.linksOffline "http://developer.android.com/reference", androidJavadocOffline
}

configure (androidProjects) {
    task compileAndroid(type: JavaCompile) {
        source = compileJava.source
        classpath = compileJava.classpath
        destinationDir = new File(buildDir, 'android')
        options.bootClasspath = androidBootClasspath
    }
}

test { dependsOn androidProjects*.compileAndroid }

对此有任何帮助吗?

0 个答案:

没有答案