Fixing Build Failure in Flutter
Fix: Android Gradle Plugin (AGP) Version Issue
Error
Cause
This is likely due to a known bug in Android Gradle Plugin (AGP) versions less than 8.2.1,
Solution: Update AGP to 8.2.1 or Higher
Step 1. Upgrade Android Gradle Plugin (AGP)
Modify your android/build.gradle
file:
- Open
<app_directory>\android\settings.gradle
- Find this line:
classpath 'com.android.application:X.X.X'
Update it to:
classpath 'com.android.application:8.2.1' // Or a higher version
note
If you use older version, it may be in <app_directory>\android\build.gradle
, look for the "com.android.tools.build:gradle:" version and update it.
2. Update the Gradle Wrapper
- Open
<app_directory>/android/gradle/wrapper/gradle-wrapper.properties
- Update the Gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-bin.zip
3. Sync and Rebuild
Run the following commands in your terminal:
flutter clean
flutter pub get
flutter run
Fix: "Build Requires Symlink Support" Error
Error
Solution: Enable Developer Mode on Windows
- Open
Command Prompt
and run:
start ms-settings:developers
- Enable Developer Mode and restart your system if prompted.