Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法更改配置';的依赖项:核心:类路径';解决之后。Gradle按需配置问题_Android_Gradle_Build.gradle - Fatal编程技术网

Android 无法更改配置';的依赖项:核心:类路径';解决之后。Gradle按需配置问题

Android 无法更改配置';的依赖项:核心:类路径';解决之后。Gradle按需配置问题,android,gradle,build.gradle,Android,Gradle,Build.gradle,我有一个包含1个应用程序模块(MyApplication)和1个库模块(core)的项目。 当我试图查看“gradlew MyApplication:dependencies”时, 我有个错误 * What went wrong: A problem occurred evaluating project ':core'. > Cannot change dependencies of configuration ':core:classpath' after it has been re

我有一个包含1个应用程序模块(MyApplication)和1个库模块(core)的项目。 当我试图查看“gradlew MyApplication:dependencies”时, 我有个错误

* What went wrong: A problem occurred evaluating project ':core'.
> Cannot change dependencies of configuration ':core:classpath' after it has been resolved.
在顶级目录中,我有build.gradle,其中包含:

   ...
// 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'
    }
}
   ...
...
buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
    }
}
...
我还设置了

org.gradle.configureondemand=true

在MyApplication目录中,我有build.gradle和典型的应用程序配置

apply plugin: "com.android.application"
...
在core目录中,我有build.gradle,其中包含:

   ...
// 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'
    }
}
   ...
...
buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
    }
}
...
请询问是否需要gradle文件中的其他信息


很抱歉,它的项目在公开源代码和整个gradle文件正文方面有限制。

我终于明白了哪里出了问题。 在顶部文件夹build.gradle中,我们已经定义了与android构建工具相关的内容:

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'
    }
}
因此,我们需要从应用程序或库模块中删除此定义:

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
    }
}

我将子模块类路径移动到顶级gradle文件,然后它得到修复。