Umair
Umair

Reputation: 1877

FAILURE: Build failed with an exception (Shared preference and gradle wrapper properties)

I am getting this error when i run the flutter run --release command on terminal. Kindly help me in solving this problem and let me know where i am doing wrong to make its release build successfully.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences_macos-0.0.1+2\android\build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'shared_preferences_macos'.
> Failed to apply plugin [id 'com.android.library']
   > Minimum supported Gradle version is 5.4.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in C:\flutter\.pub-cache\hosted\pub.dartlang.org\s
hared_preferences_macos-0.0.1+2\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip

* Try:
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s


The plugin shared_preferences_macos could not be built due to the issue above.

This is my flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.535], locale en-US)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)

• No issues found!

I also updated my gradle wrapper properties to this one but got the same issue

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

Upvotes: 2

Views: 2131

Answers (1)

Kumarpalsinh Rana
Kumarpalsinh Rana

Reputation: 254

Thanks @umair for the solution. Let me give a brief understanding of solution.

We have to update the version in gradle-wrapper.properties file of respective plugins where an error is showing.

Let's say if error is showing for "shared_preferences_macos" then we have to update version number in gradle-wrapper.properties file of "shared_preferences_macos" plugin from below path.

PATH: /Users/admin/Library/Android/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+3/android/gradle/wrapper/gradle-wrapper.properties

From the above path we have to open gradle-wrapper.properties file and have to update version to 5.4.1 from 4.10.2 in distributionUrl variable and save the file. That's it.

Note:

  • A path for gradle-wrapper.properties file of the respective plugin will be shown on your terminal error message
  • Suggested Gradle version will also be shown on your terminal error message
  • Repeat the same process for all the plugins where you were facing an error message.

Upvotes: 4

Related Questions