Gradle构建报错:要求最低版本4.4,当前为4.3但Wrapper已设为4.4
Hey there! Let's work through this frustrating Gradle version error you're hitting. You've already updated the Gradle Wrapper's distributionUrl and the Android Gradle Plugin classpath, but the build still complains about using 4.3 instead of 4.4. Here are some additional steps to fix this:
Check your global Gradle installation
Sometimes your system's globally installed Gradle takes precedence over the project wrapper. Open a terminal and rungradle -v—if it outputs version 4.3, that's the culprit. Instead of usinggradle buildto run your build, always use the wrapper command:./gradlew build(on macOS/Linux) orgradlew.bat build(on Windows). If you want to update your global Gradle, you can download version 4.4 manually and replace the old installation.Wipe Gradle caches and build artifacts
Stale cache files might be holding onto the old Gradle version reference. Do the following:- Delete the
.gradlefolder in your project's root directory - Delete the
buildfolders in both your project root and all modules (likeapp/build) - Run
./gradlew clean build --refresh-dependenciesto force a clean build and refresh all dependencies
- Delete the
Verify Android Studio's Gradle settings
If you're using Android Studio, make sure it's configured to use the project wrapper:- Go to
File > Settings > Build, Execution, Deployment > Build Tools > Gradle - Under "Use Gradle from", select "gradle-wrapper.properties file" (not a local Gradle installation)
- Also double-check that your Gradle JDK is set to Java 8—Gradle 4.4 requires Java 8 or newer, and an incompatible JDK can cause unexpected version issues
- Go to
Regenerate the Gradle Wrapper files
Your wrapper files might be corrupted. Run this command in your project root to regenerate them with the correct version:./gradlew wrapper --gradle-version 4.4 --distribution-type allThis will overwrite the existing wrapper configuration and ensure all related files point to Gradle 4.4.
Check your system PATH variable
If your global Gradle's path is in your system'sPATHenvironment variable, it might be overriding the wrapper. Temporarily remove the global Gradle path fromPATHand try building again with the wrapper command to test if that fixes it.
内容的提问来源于stack exchange,提问作者udarts

