我有一个gradle FAILURE:

..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."

案例描述:

附加到项目代码库的下一个库:

APP / build.gradle

    //(Required) Writing and executing Unit Tests on the JUnit Platform 
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
    // (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
    // (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"

testImplementation "io.mockk:mockk:1.8.5"

更新gradle-wrapper.properties distributionUrl=https....gradle-4.4-all.zip到4.7-all .zip 毕竟,gradle是建立成功的 创建测试类 @TestInstance (TestInstance.Lifecycle.PER_CLASS) 类TestClass { @Test 内部乐趣testName() { 断言。assertEquals(2,1 + 1) } } 运行测试并得到FAILURE消息。 运行Gradle构建时使用命令行参数./gradlew——warning-mode=all来查看哪些特性被弃用了。

结果,我无法构建应用程序,我得到了FAILURE:消息。


当前回答

在上面的答案对我都不起作用后,我设法通过将Gradle插件升级到最新版本并使用JDK 11来解决这个问题。 希望这能帮助到一些人!

其他回答

试试这个方法对我有用。 如果您在设备上有另一个具有相同名称(或包名)的应用程序:重命名应用程序或从设备上删除它。

解决方法: 在这个版本中使用了已弃用的gradle特性,使得它与gradle 6.0不兼容。android工作室 这个解决方案对我很有效。

首先更改build依赖项中的类路径。Gradle你的项目 From: classpath 'com.android.tools.build:gradle:3.3.1' 到:classpath 'com.android.tools.build:gradle:3.6.1'

然后在gradle-wrapper中进行更改。该文件存在于项目的gradle>包装器文件夹中 来自:distributionUrl = https \: / / services.gradle.org/distributions/gradle-5.4.1-all.zip : distributionUrl = https \: / / services.gradle.org/distributions/gradle-5.6.4-all.zip

然后同步你的gradle。

从设备/模拟器卸载旧的应用程序。这对我很有效

检查设置。Gradle脚本并删除jcenter(),它可能会导致问题,因为它已弃用。

你是新设置。Gradle文件应该是

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    plugins {
        id 'com.android.application' version '7.1.0-alpha12'
        id 'com.android.library' version '7.1.0-alpha12'
        id 'org.jetbrains.kotlin.android' version '1.5.21'
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "ComposePlayground"
include ':app'

注意ComposePlayground是应用程序名称。

On a SpringBoot project using IntelliJ and Gradle, I got the warning "Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0" when running my integration test. What solved the problem was: - Going to: File > Settings > Build, Execution, Deployment - Selecting for "Build and run using": Intellij IDEA (instead of "Gradle") - Same for "Run tests using" That did not explain why Gradle is displaying the warning, but that let me perform the test and progress in my work.