此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容

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

我有一个 gradle 失败:

..."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 使用命令行参数构建 --warning-mode=all 以查看弃用的功能。

它将为您详细描述所发现的问题,并提供指向 Gradle 文档的链接,以了解如何修复您的构建。

向其中添加 --stacktrace,如果警告是由其中一个插件中的过时代码而非您的构建脚本触发的,您还可以查明警告的来源。

最终决定将junit 5降级为junit 4并重建测试环境

将 gradle-wrapper-properties 文件中的 distributionUrl 路径设置为:

distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip

更新您的第三方依赖项。 例如我更新了依赖 implementation 'com.github.ybq:Android-SpinKit:1.1.0'implementation 'com.github.ybq:Android-SpinKit:1.2.0'。就我而言,问题已经解决。

我遇到了这个错误。原来只有当我完全清理 RN 缓存(相当复杂的过程)然后创建发布版本时才会发生这种情况。

如果我清理缓存,创建调试版本,然后创建发布版本,一切正常。有点担心但有效。

注意:我的清理命令是...

rm -r android/build ; rm -r android/app/src/release/res ; rm -r android/app/build/intermediates ; watchman watch-del-all ; rm -rf $TMPDIR/react-* ; npm start -- --reset-cache

重要 - 答案仅适用于 REACT-NATIVE VS CODE 终端

在 VisualStudio 代码中,您必须像下面那样 运行 然后警告将被忽略。

react-native 运行-android warning-mode=all

If you run below then you will get the error in terminal When running react-native run-android --warning-mode all I get error: unknown option --warning-mode'

问题解决方案: 此版本中使用了已弃用的 gradle 功能,使其与 gradle 6.0 不兼容。 android工作室 这个提供的解决方案对我有用。

首先更改项目 build.gradle 的依赖项中的类路径 来自:classpath 'com.android.tools.build:gradle:3.3.1' 收件人:classpath 'com.android.tools.build:gradle:3.6.1'

然后在 gradle-wrapper.properties 文件中进行更改,此文件存在于项目的 gradle>wrapper 文件夹中 来自: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。

试试这个

cd android && ./gradlew clean && ./gradlew :app:bundleRelease

在使用 IntelliJ 和 Gradle 的 SpringBoot 项目中,我在 运行 集成测试时收到警告 "Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0"。 解决问题的方法是: - 前往:文件 > 设置 > 构建、执行、部署 - 选择 "Build and run using":Intellij IDEA(而不是 "Gradle") - "Run tests using" 相同 这并没有解释为什么 Gradle 显示警告,但这让我可以进行测试并在我的工作中取得进展。

在我的例子中,我更新了 build.gradle 文件并将 classpath 设为最新版本,从 3.5.23.6.3

dependencies {
        classpath("com.android.tools.build:gradle:3.6.3") 
    }

迁移到 AndroidX

后修复了此类错误
  • 转到重构 ---> 迁移到 AndroidX

以下解决方案帮助了我,因为我也收到了同样的警告。 在您的项目级别 gradle 文件中,尝试更改类路径

中的 gradle 版本
classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"

在react-native的项目中这个问题对我有用:

此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。

244 项可操作任务:2 项已执行,242 项是最新的 D8:无法在单个 dex 文件中容纳请求的 类(# 字段:67296 > 65536) com.android.builder.dexing.DexArchiveMergerException:合并 dex 档案时出错: .dex 文件中的方法引用数不能超过 64K。 在 https://developer.android.com/tools/building/multidex.html 了解如何解决此问题 ....

我这样做了:

  • 从我的设备上卸载应用程序:

在我的例子中,在 Android/app/build.gradle 文件中添加 multiDexEnabled true 编译文件。

我会考虑在将来删除它,因为在 documentation 它说 'Before configuring your app to enable use of 64K or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or included libraries.'

defaultConfig {
  applicationId "com.peoplesenergyapp"
  minSdkVersion rootProject.ext.minSdkVersion
  targetSdkVersion rootProject.ext.targetSdkVersion
  versionCode 1
  versionName "1.0"
  multiDexEnabled true // <-add this 
}

卸载 device/emulator 中的旧应用。它对我有用

我正在使用 react-native,这对我有用:

  1. 在项目 cd androidgradlew clean
  2. 的根目录中
  3. 在 windows
  4. 中打开任务管理器
  5. 在选项卡上 'Details' 在两个 java.exe 进程上都点击结束任务

长话短说 > Task :app:installDebug FAILEDkiling java.exe prossess

修复

不兼容造成的

请升级 android 文件夹下的 build.gradle 文件中的 classpath("com.android.tools.build:gradle:4.0.1")

以下过程适用于我的情况- 首先查看 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并更改classpath 'com.android.tools.build:gradle:<plugin_version>

我发现我的磁盘 space 小于 4 GB,无法获取 Gradle 库库 然后显示

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 和垃圾文件,释放 space 然后尝试构建并解决问题

在我的例子中,从基本目录中删除了整个 android 文件夹并允许它在 eas build 上重建所有文件夹为我修复了这个错误:)

implementation("org.slf4j:slf4j-nop:1.7.25") 添加到 build.gradle.kts

检查 settings.gradle 脚本并从中删除 jcenter() 它可能会导致问题,因为它已被弃用。

你是新手settings.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'

Take note that ComposePlayground is app name.

我的项目与 Gradle 8.0 不兼容。以下是对我有用的: 首先我在Android Studio 终端写了这行代码:

./gradlew build --warning-mode all

当您这样做时,您将在 logcat 中看到发现已弃用的内容或项目中的问题,对我来说是 jcenter() 存储库需要删除在我的 settings.gradle 文件中,我还需要在我的 build.gradle 项目文件中将 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" 更新为 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"

完成这些操作后,我的项目完美构建并安装在我的模拟器上

我通过更新 gradle-wrapper.properties 文件解决了这个问题。您必须更改此行 distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip 到最新的 gradle 版本,可以在 The Gradle Wrapper.

找到

希望对外面的人有所帮助:)

试试这个对我有用的解决方案。
如果您的设备上有另一个同名应用(或程序包名称):重命名该应用或将其从您的设备.

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

1)CD android 2) ./gradlew 干净 3)./gradlew:app:bundleRelease

然后最后安装 npm install 命令

我正在使用 react-native 如果以上方法都不起作用删除 Build.gridle 文件夹 Android 文件夹和 运行 再次解决了我的问题