BACK
Feb 16, 2025
Script to Update the Android Project Settings
Tired of dealing with Gradle and other build errors on Android? 🤮
Me too! So, I built a script to fix it all at once:
Gradle version
Java version
NDK version
Min SDK
Target SDK
The result? Faster updates and fewer headaches.
To use the Windows batch script I provided for updating Gradle, Java, and Android project settings in your Flutter project, follow these steps:
Save the Script: Copy the entire script into a text file and save it with a
.batextension, for example,update_flutter_android.bat.Place Script in Project Root: Ensure you place this batch script in the root folder of your Flutter project — the same directory containing the
pubspec.yamlfile.Open Command Prompt or PowerShell:
Press
Win + R, typecmdorpowershell, and press Enter to open a terminal.For administrative permissions (recommended for updates), right-click Command Prompt or PowerShell and choose "Run as administrator".
Run the Script:
Navigate to your Flutter project root in the terminal, e.g.,
cd C:\path\to\your\flutter_project.Execute the script by typing its filename, e.g.,
update_flutter_android.bat, and press Enter.
Script Actions:
It verifies that it is running inside a Flutter project by checking for
pubspec.yaml.It checks for the presence of the
androiddirectory.Backups of critical files like
gradle-wrapper.properties,build.gradle,settings.gradleare created.Gradle wrapper is updated safely via the Gradle command.
The build files (
build.gradleorbuild.gradle.kts) are updated with the desired Java version, NDK version, minSdk, and targetSdk.The Android Gradle Plugin version is updated in
settings.gradleorsettings.gradle.kts.On completion, it advises running
flutter cleanandflutter pub getto finalize changes.
More