简体   繁体   English

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

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

I've got a gradle FAILURE:我有一个 gradle 故障:

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

Case description:案例描述:

  • Attached to the project codebase the next libs:附加到项目代码库的下一个库:

APP/build.gradle 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"
  • Updated the gradle-wrapper.properties更新了gradle-wrapper.properties

    distributionUrl=https....gradle- 4.4-all .zip to 4.7-all distributionUrl=https....gradle- 4.4-all .zip 到4.7-all

  • after all of that gradle was built success毕竟 gradle 是成功建造的

  • created the test calss创建了测试课程

    @TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestClass { @Test internal fun testName() { Assert.assertEquals(2, 1 + 1) } }
  • ran the test and got the FAILURE message.运行测试并收到 FAILURE 消息。 在此处输入图像描述

  • ran the Gradle build with a command line argument ./gradlew --warning-mode=all to see what exactly the deprecated features are.使用命令行参数运行 Gradle 构建./gradlew --warning-mode=all以查看已弃用的功能到底是什么。 在此处输入图像描述

As a result I couldn't build the app and I've got that FAILURE: message.结果,我无法构建应用程序,并且收到了 FAILURE: 消息。

Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.使用命令行参数--warning-mode=all运行 Gradle 构建以查看不推荐使用的功能究竟是什么。

It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.它将为您提供所发现问题的详细描述,并提供指向 Gradle 文档的链接,以获取有关如何修复您的构建的说明。

Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.添加--stacktrace ,如果它是由插件之一中的过时代码而不是您的构建脚本触发的,您还可以查明警告的来源。

试试这个

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

I was getting this error.我收到这个错误。 Turns out it only happened when I completely cleaned the RN caches (quite elaborate process) and then created a release build.事实证明,只有当我完全清理 RN 缓存(相当复杂的过程)然后创建发布版本时才会发生这种情况。

If I cleaned the caches, created a debug build and then a release build, everything worked.如果我清理了缓存,创建了一个调试版本,然后是一个发布版本,一切正常。 Bit worrying but works.有点担心,但有效。

Note: My clean command is...注意:我的干净命令是...

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

in my case i updated the build.gradle file and make the classpath to latest version from 3.5.2 to 3.6.3就我而言,我更新了build.gradle文件并将classpath3.5.2设置为最新版本到3.6.3

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

In my case adding multiDexEnabled true in Android/app/build.gradle file compiled the files.在我的情况下,在 Android/app/build.gradle 文件中添加 multiDexEnabled true 编译文件。

I will look into removing this in the future, as in the documentation it says '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.'我将来会考虑删除它,因为在文档中它说“在配置您的应用程序以启用 64K 或更多方法引用之前,您应该采取措施减少应用程序代码调用的引用总数,包括方法由您的应用程序代码或包含的库定义。

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

Important - Answer work only for REACT-NATIVE VS CODE Terminal重要 - 仅适用于 REACT-NATIVE VS CODE 终端的回答工作

In VisualStudio code, you have to run like below then that warning will be omitted.在 VisualStudio 代码中,您必须像下面这样运行,然后该警告将被忽略。

react-native run-android warning-mode=all react-native run-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'如果你在下面运行,那么你会在终端中得到错误当运行 react-native run-android --warning-mode all 我得到错误:unknown option --warning-mode'

My project was incompatible with Gradle 8.0 .Here's what worked for me: First I wrote this line of code in the Android Studio terminal:我的项目与 Gradle 8.0 不兼容。这对我有用:首先我在 Android Studio 终端中编写了这行代码:

./gradlew build --warning-mode all

When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.当您这样做时,您将在 logcat 中显示发现已弃用的内容或项目中的问题,对我来说,需要在我的settings.gradle文件中删除jcenter()存储库,我也需要在我的build.gradle项目文件classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"

Once I did these things, my project built perfectly and installed on my emulator一旦我做了这些事情,我的项目就完美构建并安装在我的模拟器上

Update your third party dependencies.更新您的第三方依赖项。 for example I updated dependency from implementation 'com.github.ybq:Android-SpinKit:1.1.0' to implementation 'com.github.ybq:Android-SpinKit:1.2.0' .例如,我将依赖从implementation 'com.github.ybq:Android-SpinKit:1.1.0'implementation 'com.github.ybq:Android-SpinKit:1.2.0' and in my case issue has been solved.就我而言,问题已解决。

The following solution helped me as I was also getting the same warning.以下解决方案对我有所帮助,因为我也收到了相同的警告。 In your project level gradle file, try to change the gradle version in classpath在您的项目级 gradle 文件中,尝试更改 classpath 中的 gradle 版本

classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"

It work for me in this issue in a project of react-native:在 react-native 的项目中,它在这个问题中对我有用:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。

244 actionable tasks: 2 executed, 242 up-to-date D8: Cannot fit requested classes in a single dex file (# fields: 67296 > 65536) com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K. 244 个可操作任务:2 个已执行,242 个最新 D8:无法在单个 dex 文件中容纳请求的类(# 字段:67296 > 65536)com.android.builder.dexing.DexArchiveMergerException:合并 dex 档案时出错:数字.dex 文件中的方法引用数不能超过 64K。 Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html ....https://developer.android.com/tools/building/multidex.html了解如何解决此问题....

I Did this:我这样做了:

The process below worked in my case- First check Gradle Version:以下过程适用于我的情况 - 首先检查 Gradle 版本:

cd android
./gradlew -v

In my case it was 6.5就我而言,它是 6.5

Go to https://developer.android.com/studio/releases/gradle-plugin and you'll get the plugin version for your gradle version.转到https://developer.android.com/studio/releases/gradle-plugin ,您将获得 gradle 版本的插件版本。 For gradle version 6.5, the plugin version is 4.1.0对于 gradle 6.5 版,插件版本为 4.1.0

Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>然后转到app/build.gradle并更改classpath 'com.android.tools.build:gradle:<plugin_version>

最后决定将junit 5降级为junit 4,重建测试环境。

Set distributionUrl path in gradle-wrapper-properties files as :将 gradle-wrapper-properties 文件中的 distributionUrl 路径设置为:

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

Solution for the issue: deprecated gradle features were used in this build making it incompatible with gradle 6.0.问题的解决方案:此版本中使用了已弃用的 gradle 功能,使其与 gradle 6.0 不兼容。 android studio This provided solution worked for me. android studio 这提供的解决方案对我有用。

First change the classpath in dependencies of build.gradle of your project From: classpath 'com.android.tools.build:gradle:3.3.1' To: classpath 'com.android.tools.build:gradle:3.6.1'首先更改项目 build.gradle 依赖项中的classpath 'com.android.tools.build:gradle:3.3.1' From: classpath 'com.android.tools.build:gradle:3.3.1' To: classpath 'com.android.tools.build:gradle:3.6.1'

Then make changes in the gradle-wrapper.properties file this file exists in the Project's gradle>wrapper folder From: distributionUrl=https\\://services.gradle.org/distributions/gradle-5.4.1-all.zip To: distributionUrl=https\\://services.gradle.org/distributions/gradle-5.6.4-all.zip然后在 gradle-wrapper.properties 文件中修改这个文件存在于 Project 的 gradle>wrapper 文件夹中 From: distributionUrl=https\\://services.gradle.org/distributions/gradle-5.4.1-all.zip To: distributionUrl=https\\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Then Sync your gradle.然后同步你的gradle。

i'am using react-native and this works for me :我正在使用 react-native,这对我有用:

  1. in root of project cd android and gradlew clean在项目cd androidgradlew clean根目录中
  2. open task manager in windows在windows中打开任务管理器
  3. on tab 'Details' hit endtask on both java.exe proccess在选项卡上的“详细信息”中点击了 java.exe 进程上的 endtask

long story short > Task :app:installDebug FAILED Fixed by kiling java.exe prossess长话短说> Task :app:installDebug FAILED通过kiling java.exe prossess修复

Solved this issue by deleting the .gradle folder from /android and again run npm run android, and it solved this error.通过从 /android 中删除 .gradle 文件夹并再次运行 npm run android 解决了这个问题,它解决了这个错误。 Here's a link to the issue: https://github.com/facebook/react-native/issues/28954这是该问题的链接: https ://github.com/facebook/react-native/issues/28954

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

Uninstall the old app from the device/emulator.从设备/模拟器卸载旧应用程序。 It worked for me它对我有用

1)cd android 2) ./gradlew clean 3)./gradlew :app:bundleRelease 1)cd android 2) ./gradlew clean 3)./gradlew :app:bundleRelease

then last install npm install command然后最后安装 npm install 命令

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.在使用 IntelliJ 和 Gradle 的 SpringBoot 项目中,我在运行集成测试时收到警告“此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容”。 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.解决问题的是: - 转到:文件 > 设置 > 构建、执行、部署 - 选择“构建和运行使用”:Intellij IDEA(而不是“Gradle”) - 与“运行测试使用”相同 没有解释为什么 Gradle 显示警告,但这让我在工作中执行测试和进度。

It was fixed this kind of error after migrate to AndroidX迁移到AndroidX后修复了这种错误

  • Go to Refactor ---> Migrate to AndroidX转到重构 ---> 迁移到 AndroidX

it is due to incompatibility.这是因为不兼容。

please upgrade classpath("com.android.tools.build:gradle:4.0.1") in build.gradle file under android folder.请在android文件夹下的build.gradle文件中升级classpath("com.android.tools.build:gradle:4.0.1")

I found my disk space is less than 4 GB and can not get the Gradle lib repo then show我发现我的磁盘空间小于 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.

just remove tmp and junk files, free up space then try build and resolve problem只需删除 tmp 和垃圾文件,释放空间然后尝试构建并解决问题

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

检查settings.gradle<\/strong>脚本并jcenter()<\/code>删除可能导致问题的jcenter()<\/code> ,因为它已被弃用。

你是新的settings.gradle<\/strong>文件应该是

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'

I Sloved this problem by updating my gradle-wrapper.properties file.我通过更新我的 gradle-wrapper.properties 文件解决了这个问题。 You have to change this line distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip to the lates gradle build which can be found at The Gradle Wrapper .您必须将此行distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip更改为最新的 gradle 版本,可以在Gradle Wrapper中找到。

Hope that helps someone out there :)希望对那里的人有所帮助:)

Try this solution worked for me.试试这个解决方案对我有用。
If you have another app with the same name (or package name ) on the device: Rename the app or delete it from your device .如果您的设备上有另一个同名(或包名)的应用程序:重命名该应用程序或将其从您的设备中删除

For me, the problem was that I ran out of space in my device's internal storage.对我来说,问题是我的设备内部存储空间不足。 After deleting a few unnecessary apps, it worked fine.删除一些不必要的应用程序后,它工作正常。

after hours of searching on the web i used this command [react-native run-android warning-mode=all] on vs code .在网上搜索了几个小时后,我在 vs code 上使用了这个命令 [react-native run-android warning-mode=all]。 and it turns out that the error have nothing to do with deprecated moduls or any gradle error it was just that my device was full of storage , hope it helps some one in some day.事实证明,该错误与不推荐使用的模块或任何 gradle 错误无关,只是我的设备已满存储空间,希望有一天能对某些人有所帮助。

Go to gradle/wrapper/gradle-wrapper.properties change the distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip to the release that is needed (or higher).转到gradle/wrapper/gradle-wrapper.propertiesdistributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip更改为所需的版本(或更高版本)。

Then run again cd android && ./gradlew bundleRelease然后再次运行cd android && ./gradlew bundleRelease

I have the same issue with a project, when trying to run ./gradlew runTest command:在尝试运行./gradlew runTest命令时,我对项目有同样的问题:

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

The only difference is that I had no problems working with this project on Windows.唯一的区别是我在 Windows 上使用这个项目没有任何问题。 Now I changed my computer to Mac and guess - the issue is in my environment or IDE settings.现在我将计算机更改为 Mac 并猜测 - 问题出在我的环境或 IDE 设置中。 I have no permission to change project code.我无权更改项目代码。 Can anyone give an advice, how to solve this issue?谁能给个建议,如何解决这个问题?

implementation("org.slf4j:slf4j-nop:1.7.25")<\/code>到build.gradle.kts<\/code> 。

"

If you're using react-native then please try the below commands first before running your project:如果您使用的是react-native,请在运行项目之前先尝试以下命令:

  1. npm install --save-dev jetifier npm install --save-dev jetifier
  2. npx jetify npx喷气机

Now run your project again.现在再次运行您的项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gitlab CI / CD显示在此版本中使用了不推荐使用的Gradle功能,使其与Gradle 5.0不兼容 - Gitlab CI/CD Show Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6 不兼容 - Deprecated Gradle features were used in this build, making it incompatible with Gradle 6 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle X 不兼容 - Deprecated Gradle features were used in this build, making it incompatible with Gradle X 更新后无法构建 android 项目,错误:此构建中使用了已弃用的 Gradle 功能,使其与 Gradle 5.0 不兼容 - Cannot build android project after updating, error: Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 当我执行 gradle lint 时出现错误“此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容” - Error "Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0" When I do gradle lint Unity Android 构建错误 - 此构建中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容 - Error on Unity Android Build - Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0 “此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。” -反应原生 - "Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0." -REACT-NATIVE Task:app:mergeReleaseResources FAILED, Deprecated Gradle features used in this build, 使其与 Gradle 7.0 不兼容 - Task :app:mergeReleaseResources FAILED, Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容。 - 反应原生 - Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. - React native React Native Task :app:processDebugResources FAILED 已弃用的 Gradle 功能在此构建中使用,使其与 Gradle 7.0 不兼容 - React native Task :app:processDebugResources FAILED Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM