【问题标题】:Unable to find method 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'找不到方法 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'
【发布时间】:2019-10-24 07:55:51
【问题描述】:

当我尝试构建签名的 apk 时,我开始遇到以下问题:

Unable to find method 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

这是我的 gradle.properties:

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

这里是android.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

    标签: android android-build


    【解决方案1】:

    将类路径 com.android.tools.build:gradle 更新为项目 gradle 中的最新版本。

    classpath 'com.android.tools.build:gradle:3.5.1'
    

    【讨论】:

    • 这个指令应该在哪里添加?
    • @Kubuntuer82,将此添加到项目级 build.gradle 文件中
    【解决方案2】:
    Change Gradle properties 
    
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
    
    
    Change distributional like below then it will works 
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
    

    【讨论】:

      【解决方案3】:

      我使用 IntelliJ,我是否使用 gradle wrapper,我得到了:

      Unable to find method 'org.gradle.api.tasks.SourceSet.getCompileConfigurationName()Ljava/lang/String;'.
      

      我在 Gradle 属性中更改了我的 gradle 版本,但它不起作用,所以我改用本地 gradle 分发,并且它可以正常工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多