Android Cannot change dependencies of configuration ':compile' after it has been included in dependency resolution

那年仲夏 提交于 2019-12-11 20:41:07

问题


I could not able to build my library module on Android studio. I got the following exception in build.gradle file:

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

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

I am using Android studio 3.2.1 and Gradle version is 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 }

Any help on this?

来源:https://stackoverflow.com/questions/53300594/android-cannot-change-dependencies-of-configuration-compile-after-it-has-been

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!