我有一个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:消息。


当前回答

我使用反应本机,如果以上都没有工作,删除构建和。gridle文件夹内的Android文件夹,并再次运行,这解决了我的问题

其他回答

通过从/android中删除.gradle文件夹并再次运行npm run android解决了这个问题,它解决了这个错误。 这是问题的链接:https://github.com/facebook/react-native/issues/28954

下面的过程对我来说是有效的 首先检查Gradle版本:

cd android
./gradlew -v

我的情况是6.5

去https://developer.android.com/studio/releases/gradle-plugin,你会得到你的gradle版本的插件版本。对于gradle 6.5版本,插件版本为4.1.0

然后进入app/build。Gradle:<plugin_version>

检查设置。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是应用程序名称。

我发现我的磁盘空间不足4 GB,无法获得Gradle lib repo 然后显示

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

只需删除TMP和垃圾文件,释放空间,然后尝试构建和解决问题

使用命令行参数——warning-mode=all运行Gradle构建,查看哪些特性被弃用。

它会给你一个详细的描述发现的问题与链接到Gradle文档指导如何修复你的构建。

在此基础上添加——stacktrace,如果警告是由某个插件中的过时代码而不是你的构建脚本触发的,你也可以精确地指出警告的来源。