简体   繁体   English

更新 android studio 后出现错误“支持的最低 Gradle 版本为 5.1.1。当前版本为 4.4.1”

[英]Error "Minimum supported Gradle version is 5.1.1. Current version is 4.4.1" after update android studio

I updated android studio from 3.3 to 3.4 version and after install and do ./gradlew lint I am getting the next error:我将 android studio 从 3.3 更新到 3.4 版本,安装并执行./gradlew lint后,我​​收到下一个错误:

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

Then I use the next command to get more details:然后我使用下一个命令来获取更多详细信息:

  ./gradlwe build --warning-mode=all

And I get the next message:我收到下一条消息:

Failed to apply plugin [id 'com.android.application']无法应用插件 [id 'com.android.application']

Minimum supported Gradle version is 5.1.1.支持的最低 Gradle 版本为 5.1.1。 Current version is 4.4.1.当前版本是 4.4.1。 If using the gradle wrapper, try editing the distributionUrl in .gradle/daemon/4.4.1/gradle/wrapper/gradle-wrapper.properties to gradle-5.1.1-all.zip如果使用 gradle 包装器,请尝试将 .gradle/daemon/4.4.1/gradle/wrapper/gradle-wrapper.properties 中的 distributionUrl 编辑为 gradle-5.1.1-all.zip

And when I edited my gradle-wrapper.properties, I see that the changes were already done, IE the version of the distributionUrl already was gradle-5.1.1.-all.zip当我编辑我的 gradle-wrapper.properties 时,我看到更改已经完成,IE 的distributionUrl版本已经是 gradle-5.1.1.-all.zip

Any idea that how can resolve this?知道如何解决这个问题吗?

您可以编辑 YOUR_APPLICATION_FOLDER/gradle/wrapper/gradle-wrapper.properties 并将最后一行更改为: distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip Android Studio 将下载必要的图书馆。

This was my solution.这是我的解决方案。

My_project
  /gradle
  /wrapper
  /gradle-wrapper.properties 

Modify this line with the Gradle 5.1.1使用 Gradle 5.1.1 修改此行

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

最后,我能够解决这个问题,在~/.gradle/wrapper/dists中删除最旧版本的文件夹,只留下gradle-5.1.1-all

In my case, gradle failed to download the version I specified though I tried all previous solutions.就我而言,尽管我尝试了所有以前的解决方案,但 gradle 未能下载我指定的版本。

Apparently, I was opening my project by selecting "MyProject/App" directory.显然,我通过选择“MyProject/App”目录打开了我的项目。 Gradle successfully updated when I opened the same project by selecting the "MyProject" folder.当我通过选择“MyProject”文件夹打开同一个项目时,Gradle 成功更新。

  1. Check your full project and find all "Gradle-wrapper.properties" files.检查您的完整项目并找到所有“Gradle-wrapper.properties”文件。 If your project has multiple modules then there are chances of having multiple.如果您的项目有多个模块,那么就有可能有多个。 and set -并设置 -

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

  1. Gradle sync Gradle 同步

  2. If not done then invalidate the cache and restart the project.如果未完成,则使缓存无效并重新启动项目。

  3. Still not working then go to your root directory on Linux and find .gradle folder.仍然无法正常工作,然后转到 Linux 上的根目录并找到 .gradle 文件夹。 Delete it and restart the android studio.删除它并重新启动android studio。

If you use Ubuntu and all above answers didn't solve your problem try to upgrade gradle on your Ubuntu with this commands from this answer https://askubuntu.com/a/975018/714791如果您使用 Ubuntu 并且以上所有答案都没有解决您的问题,请尝试使用此答案https://askubuntu.com/a/975018/714791中的此命令在您的 Ubuntu 上升级 gradle

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt upgrade gradle

It will help I hope我希望这会有所帮助

I resolved by two below steps.我通过以下两个步骤解决了。

  1. delete gradle folder删除 gradle 文件夹
  2. check your classpath 'com.android.tools.build:gradle:{$gradleVersion}检查你的类路径 'com.android.tools.build:gradle:{$gradleVersion}

My gradleVersion is 3.5.3.我的 gradleVersion 是 3.5.3。

我通过更改gradle/wrapper中的gradle-wrapper.properties中的distributionUrl解决了这个问题,而不是gradle.properties

Maybe it's your gradle environment variable.也许这是你的 gradle 环境变量。 execute 'gradle -v' Check that the gradle version of the project matches the gradle environment variable version执行 'gradle -v' 检查项目的 gradle 版本是否与 gradle 环境变量版本匹配

those who are still facing issue with Cordova/Ionic, this is due to CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL which is being checked at platforms/android/cordova/lib/builders/GradleBuilder.js那些仍然面临 Cordova/Ionic 问题的人,这是由于正在检查平台CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URLplatforms/android/cordova/lib/builders/GradleBuilder.js

set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL to desired distributionalCORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL设置为所需的分布

for MacOs适用于 MacO

export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL = https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

I think it's very important to mention which IDE you're using and what are the configurations.我认为提及您使用的 IDE和配置是非常重要的。 What made me upset was, I had a setting in gradle-wrapper.properties file which was "ignored" to my mind.让我感到不安的是,我在 gradle-wrapper.properties 文件中有一个设置在我的脑海中被“忽略”了。

I've found the settings in the IDEA application settings , there:我在 IDEA 应用程序设置中找到了设置,有: 在此处输入图像描述

and then selecting:然后选择:

在此处输入图像描述 and everything works as expected.一切都按预期工作。

Deleting 'all other' locally cached versions can never be the right solution ;)删除“所有其他”本地缓存版本永远不是正确的解决方案;)

Good luck!祝你好运!

My app is using Cordova v9.0.0我的应用正在使用 Cordova v9.0.0

distributionUrl is set at platforms\android\cordova\lib\builders\ProjectBuilder.js distributionUrl设置在platforms\android\cordova\lib\builders\ProjectBuilder.js

You can set distributionUrl from the command line with您可以从命令行设置distributionUrl

set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="https://services.gradle.org/distributions/gradle-[version]-all.zip"

Replace [version] with your preference将 [version] 替换为您的偏好

it solved for me get the flutter SDK directory它为我解决了获得颤振 SDK 目录

this is my flutter Sdk C:\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_macos-0.1.0+2\android\gradle\wrapper这是我的颤振 Sdk C:\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_macos-0.1.0+2\android\gradle\wrapper

change gradle-wrapper.properties更改 gradle-wrapper.properties

Modify this line with the Gradle 5.1.1使用 Gradle 5.1.1 修改此行

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

I had the same error: Error "Minimum supported Gradle version is 6.1.1. Current version is 5.1.1" but when I opened the gradle.properties and I found this "distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip" which was correct but wasn't working.我遇到了同样的错误:错误“支持的最低 Gradle 版本是 6.1.1。当前版本是 5.1.1”但是当我打开 gradle.properties 并发现这个“distributionUrl=https://services.gradle.org/distributions /gradle-6.1.1-all.zip"这是正确的,但没有工作。 To solve this, I deleted the ".gradle" file in the explorer, reopened the app and found out the distributionUrl had change to 5.2.2-all.zip in gradle.properties;为了解决这个问题,我删除了资源管理器中的“.gradle”文件,重新打开应用程序,发现 gradle.properties 中的distributionUrl已更改为5.2.2-all.zip I then edited to 6.1.1-all.zip and sync and everything worked like a charm.然后我编辑到6.1.1-all.zip并同步,一切都像一个魅力。 I hope this can help someone else.我希望这可以帮助别人。

Try to download manually Gradle-5.1.1 from https://gradle.org/releases then go to file/project structure/project and put the new version in gradle version.尝试从https://gradle.org/releases手动下载 Gradle-5.1.1,然后转到文件/项目结构/项目并将新版本放入 gradle 版本。 (You can also use this link - jenv.io/candidate/gradle) (您也可以使用此链接 - jenv.io/candidate/gradle)

I was having the same problem after migrating from android.support library to androidx where junit library start with androidTestImplementation and not testImplementation .android.support库迁移到androidx后,我遇到了同样的问题,其中 junit 库以androidTestImplementation而不是testImplementation 开头

So i changed所以我改变了

testImplementation "junit:junit:$rootProject.junitVersion"

to

androidTestImplementation androidx.test.ext:junit:1.0.0-beta01

or或者

androidTestImplementation "junit:junit:$rootProject.junitVersion"


Remember to append android before testImplementation记得在 testImplementation 之前附加android

另外,尝试使用以下命令删除所有旧/不需要的 gradle 版本: cd usr/local/Cellar/gradle/

不要忘记在您的项目中运行 gradle 包装器: https ://docs.gradle.org/6.4.1/userguide/gradle_wrapper.html#sec:adding_wrapper

Delete gradle folder from your project directory as well as from the app directory.从项目目录和应用目录中删除 gradle 文件夹。

restart Adroid studio and resync gradle.重新启动 Adroid Studio 并重新同步 gradle。

it will solve your problem.它会解决你的问题。 If not you might be opened the project yourproject/app.如果没有,您可能会打开项目 yourproject/app。 close Android studio and import your project after selecting yourproject.选择您的项目后,关闭 Android Studio 并导入您的项目。 Then resync gradle.然后重新同步gradle。 This will solve your problem.这将解决您的问题。

For Windows 10:对于 Windows 10:

Go to C:\Users\<user-name>\.gradle\wrapper\dists and delete everything there.转到C:\Users\<user-name>\.gradle\wrapper\dists并删除那里的所有内容。 Android studio will download the appropriate version afterwards. Android studio 之后会下载相应的版本。

If anyone is still searching for a solution after trying literally everything, here's what worked for me.如果有人在尝试了所有内容后仍在寻找解决方案,那么这对我有用。

In the .gitlab-ci.yml file, my image: key was outdated and was writing in the script that Gradle was set to 5.1.1 even though everything in my Android Studio was 7.0.2..gitlab-ci.yml文件中,我的image: key 已过时,并且正在编写 Gradle 设置为 5.1.1 的脚本,即使我的 Android Studio 中的所有内容都是 7.0.2。 After talking to the guy who wrote the image script, I just had to increment the version of that.在与编写图像脚本的人交谈后,我只需要增加它的版本。

https://forum.gitlab.com/t/set-specific-version-of-gradle-for-ci-build/41716/4 https://forum.gitlab.com/t/set-specific-version-of-gradle-for-ci-build/41716/4

此错误已通过重新启动 Android Studio 解决。

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

相关问题 Unity错误:支持的最低Gradle版本为5.1.1 - Unity Error: Minimum supported gradle version is 5.1.1 更新至 Android Studio Chimmpunk:'支持的最低 Gradle 版本为 7.3.3。 当前版本是 7.2。 - Update to Android Studio Chimpmunk: 'Minimum supported Gradle version is 7.3.3. Current version is 7.2.' Android Studio 错误“支持的最低 Gradle 版本是 7.0.2。当前版本是 6.8。” - Android Studio Error "Minimum supported Gradle version is 7.0.2. Current version is 6.8." 错误:android studio 3.0.1 中支持的最低 gradle 版本为 4.6 - Error : minimum supported gradle version is 4.6 in android studio 3.0.1 Cordova / Ionic build android Gradle 错误:支持的最低 Gradle 版本为 2.14.1。 当前版本是 2.13 - Cordova / Ionic build android Gradle error: Minimum supported Gradle version is 2.14.1. Current version is 2.13 错误:支持的最低 Gradle 版本为 5.6.4。 当前版本是 5.2.1 - ERROR: Minimum supported Gradle version is 5.6.4. Current version is 5.2.1 Android Studio gradle最低版本错误 - Android Studio gradle minimum version error Android Studio Gradle版本5.1.1问题 - Android Studio Gradle Version 5.1.1 Problem 错误:需要Gradle 2.2版。 当前版本是5.1.1 - ERROR: Gradle version 2.2 is required. Current version is 5.1.1 Gradle 错误:支持的最低 Gradle 版本是 3.3。 当前版本是 3.2 - Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM